VBA if statement condition met to rely on multiple sheets such as sheet 1 and sheet 2 and so on?

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. 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
 
Hello

I have managed to fix the issue so your help on this really is helpful. Thanks 😊
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Good to hear you got the solution.

If you would like to post the solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top