Hello there! I have a macro programme to do some operations like Vlookup, deleting columns etc. The file to be updated would have a few worksheets in it and every time the worksheets' name and order may be different. Thus, I would like to be able to choose the worksheet I want every time I use the macro. However, I haven't be successful.....
My macro
This is just part of the macro. I wanted the mySheet to be variable. Ideally, It can prompt me to choose the worksheet I want within that wbSource..However, I have been getting errors. Anyone know how do I do it?
Thanks in advance!
My macro
Code:
Sub Macro1()
Dim file1 As String
Dim file2 As String
Dim wbSource As Workbook
Dim wbLookup As Workbook
Dim startRange As Range
Dim mySheet As Worksheet
Dim col As Range
Dim Del As Range
file1 = Application.GetOpenFilename(Title:="Select the file to update")
If Len(Dir(file1)) = 0 Then Exit Sub
file2 = Application.GetOpenFilename(Title:="Select the LOOKUP file")
If Len(Dir(file2)) = 0 Then Exit Sub
Set wbLookup = Workbooks.Open(file2)
Set wbSource = Workbooks.Open(file1)
Set mySheet = wbSource.Sheets(ActiveSheet.Name)
This is just part of the macro. I wanted the mySheet to be variable. Ideally, It can prompt me to choose the worksheet I want within that wbSource..However, I have been getting errors. Anyone know how do I do it?
Thanks in advance!