vbanewbie68
Board Regular
- Joined
- Oct 16, 2021
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
- MacOS
Hello
Would it be possible to run a macro using an if statement condition met to rely on multiple sheets such as sheet 1 and sheet 2 and even multiple sheets if necessary?
Below this coding section will rely on default on sheet 1 but I need multiple sheets please?
Thank you
Regards
V
Macro
For R = 1 To Cells(10000, 1).End(xlUp).Row
If Left(Cells(R, RefB), 14) = "Company name" Then
If Cells(R, InRE) = "" Then
'Check if date matches to label multiple payment references
If Cells(R, 1).Value = PrevDate Then
ReDim Preserve BankRefs(0 To JGCount)
BankRefs(JGCount) = "Company name" & PrevCount
PrevCount = PrevCount + 1
Else
ReDim Preserve BankRefs(0 To JGCount)
BankRefs(JGCount) = "Company"
PrevDate = "Company"
PrevCount = 2
End If
'Add a string with all required bank statement details for comparison
ReDim Preserve BankRow(0 To JGCount)
BankRow(JGCount) = R & "| " & Cells(R, 1) & " £" & Cells(R, credit)
'Add the corresponding date to its array
ReDim Preserve BankDate(0 To JGCount)
BankDate(JGCount) = Cells(R, 1).Value
'Change position in the arrays
JGCount = JGCount + 1
End If
End If
Next R
Would it be possible to run a macro using an if statement condition met to rely on multiple sheets such as sheet 1 and sheet 2 and even multiple sheets if necessary?
Below this coding section will rely on default on sheet 1 but I need multiple sheets please?
Thank you
Regards
V
Macro
For R = 1 To Cells(10000, 1).End(xlUp).Row
If Left(Cells(R, RefB), 14) = "Company name" Then
If Cells(R, InRE) = "" Then
'Check if date matches to label multiple payment references
If Cells(R, 1).Value = PrevDate Then
ReDim Preserve BankRefs(0 To JGCount)
BankRefs(JGCount) = "Company name" & PrevCount
PrevCount = PrevCount + 1
Else
ReDim Preserve BankRefs(0 To JGCount)
BankRefs(JGCount) = "Company"
PrevDate = "Company"
PrevCount = 2
End If
'Add a string with all required bank statement details for comparison
ReDim Preserve BankRow(0 To JGCount)
BankRow(JGCount) = R & "| " & Cells(R, 1) & " £" & Cells(R, credit)
'Add the corresponding date to its array
ReDim Preserve BankDate(0 To JGCount)
BankDate(JGCount) = Cells(R, 1).Value
'Change position in the arrays
JGCount = JGCount + 1
End If
End If
Next R