Get existing IE via VBA

A compressed combination of the above answers, here’s what works for me. GetIE Function (No references required.) Function GetIE() As Object ‘return an object for the open Internet Explorer window, or create new one For Each GetIE In CreateObject(“Shell.Application”).Windows() ‘Loop to find If (Not GetIE Is Nothing) And GetIE.Name = “Internet Explorer” Then Exit For … Read more

Change the Point Color in chart excel VBA

Using: ActiveWorkbook.Sheets(“Sheet1”).ChartObjects(“Chart1”).Chart.SeriesCollection(1) Color of each point is .Points(PointNumber).Interior.Color The number of points you have to cycle though is .Points.Count The value of each point is .Points(PointNumber).Value colors of the markers themselves (Applies only to line, scatter, and radar charts): .Points(PointNumber).MarkerBackgroundColor = RGB(0,255,0) ‘ green .Points(PointNumber).MarkerForegroundColor = RGB(255,0,0) ‘ red .Points(PointNumber).MarkerStyle = xlMarkerStyleCircle ‘ change the … Read more

Access files with long paths (over 260)

The technique to convert MAXFILE encumbered DOS path names to native OS path names is well established and documented. Summarizing: Prefix a path that uses a drive letter with \\?\, like \\?\C:\foo\bar\baz.txt Prefix a path that uses a file share with ‘\\?\UNC\, like \\?\UNC\server\share\baz.txt. Works well with FileSystemObject too, at least when I tested your … Read more

move files from one folder to another

Sub MoveFiles() Dim FSO As Object Dim SourceFileName As String, DestinFileName As String Set FSO = CreateObject(“Scripting.Filesystemobject”) SourceFileName = “C:\Users\Jun.xlsx” DestinFileName = “C:\Users\Desktop\Jun.xlsx” FSO.MoveFile Source:=SourceFileName, Destination:=DestinFileName MsgBox (SourceFileName + ” Moved to ” + DestinFileName) End Sub

How to check whether certain sheets exist or not in Excel-VBA? [duplicate]

Although (unfortunately) such method is not available, we can create our own function to check this.. Hope the code below fits your needs. Edit1: Added also delete statement… Sub test() If CheckSheet(Sheets(3).Name) then Application.DisplayAlerts = False Sheets(Sheets(3).Name).Delete Application.DisplayAlerts = True End If End Sub The solution I’d go for… Function CheckSheet(ByVal sSheetName As String) As … Read more

Convert month name into number

Another way Excel Formula =MONTH(1&A1) VBA Sub Sample() Dim MonthNm As String MonthNm = “September” Debug.Print Month(DateValue(“01 ” & MonthNm & ” 2012″)) End Sub or Sub Sample() Dim MonthNm As String MonthNm = “September” Debug.Print Application.Evaluate(“=MONTH(1&” & Chr(34) & MonthNm & Chr(34) & “)”) End Sub Replace