Hello All,
I have an extended code. I am attaching an excerpt from the code. I have few opened workbooks and I want to activate them but I am getting subscript out of range error. Kindly help me out.
I am getting error in this particular line
I have an extended code. I am attaching an excerpt from the code. I have few opened workbooks and I want to activate them but I am getting subscript out of range error. Kindly help me out.
VBA Code:
Sub sort()
Dim name As String
Dim i, lr, lr2, lr3 As Long
Dim wbsource, wbdest As Workbook
Dim Rngsource, RngDest As Range
Dim Rngsrcg, Rngsrch, Rngsrci, Rngsrcj, Rngsrck, Rngsrcl, Rngsrcm As Range
For i = 1 To Workbooks.Count
name = name & Workbooks(i).name & vbLf
Next
If name = "Get Data.xlsm" Then
Exit Sub
Else
Set wbsource = Workbooks(name)
End If
Set wbdest = Workbooks("Get Data.xlsm")
I am getting error in this particular line
VBA Code:
Set wbsource = Workbooks(name)