tinderbox22
Board Regular
- Joined
- Mar 9, 2010
- Messages
- 56
- Office Version
- 365
- Platform
- Windows
Hello,
I'm running a macro that first prompts the user to open a file. I would like to know if there's a way to detect if a certain file is already open and skip that step. The below is partial code, and I'm hoping to add a piece that recognizes an open file called "October Summary.xlsm" and skips the entire Application.GetOpenFilename piece:
...
Any help would be appreciated. Thank you.
I'm running a macro that first prompts the user to open a file. I would like to know if there's a way to detect if a certain file is already open and skip that step. The below is partial code, and I'm hoping to add a piece that recognizes an open file called "October Summary.xlsm" and skips the entire Application.GetOpenFilename piece:
VBA Code:
Sub Copy_To_Summary()
Dim my_FileName As Variant
Dim wb_Current As Workbook
Dim ws_Current As Worksheet
Dim wb_New As Workbook
Dim ws_New As Worksheet
Dim rg As Range
Dim Region As String
Set wb_Current = ThisWorkbook
Region = Sheets("MEDIA").Range("D1").Value
my_FileName = Application.GetOpenFilename(FileFilter:="Excel Files,*.xl*;*.xm*") 'Open File dialog box
If my_FileName <> False Then
Workbooks.Open Filename:=my_FileName
End If
Set wb_New = ActiveWorkbook
wb_Current.Activate
With Sheets("MEDIA")
Set rg = .Range("C2") 'first cell to copy
Set rg = Range(rg, .Cells(.Rows.Count, rg.Column).End(xlUp)) 'All data in that column
Set rg = rg.Resize(, 11) 'All data in columns C:M
End With
rg.Copy 'Copy selected table range
Any help would be appreciated. Thank you.