I have the following code in my workbook.
I want it to take the values of cells in the current workbook and scroll through another workbook to see if the value is present in there, and then perform a function if it is - else do nothing.
The line preceeded with a lot of ***** is the line where the error occurs in the code. It says subscript out of range, and I can't work out why.
Any ideas?!?! Please help!!!
I want it to take the values of cells in the current workbook and scroll through another workbook to see if the value is present in there, and then perform a function if it is - else do nothing.
The line preceeded with a lot of ***** is the line where the error occurs in the code. It says subscript out of range, and I can't work out why.
Any ideas?!?! Please help!!!
Code:
Sub Button1_Click()
Dim LastVersion As Integer
Dim FileString As String
Dim PreviousIssue As String
Dim i, j As Integer
Dim CurrentName As String
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
FileString = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 6)
LastVersion = Left(Right(ThisWorkbook.Name, 6), 1) - 1
PreviousIssue = FileString & LastVersion & ".xlsm"
Application.Workbooks.Open (PreviousIssue)
i = 6
j = 6
Do Until IsEmpty(Sheets("Member Details").Range("B" & i))
CurrentName = ThisWorkbook.Sheets("Member Details").Range("B" & i) & "_" & ThisWorkbook.Sheets("Member Details").Range("C" & i)
******* Do Until IsEmpty(Workbooks(PreviousIssue).Sheets("MemberData").Range("B" & j))
If Workbooks(PreviousIssue).Sheets("Member Details").Range("B" & i).Value & "_" & ThisWorkbook.Sheets("Member Details").Range("C" & i).Value = CurrentName Then
'do something
Else: j = j + 1
End If
Loop
i = i + 1
Loop
End Sub