Macro to run on certain sheets

PMTerpe

New Member
Joined
Aug 1, 2011
Messages
2
I have a macro that works fine but I must run it on each sheet. I had a friend write the macro for me so I'm still just learning how to do this stuff. I've found several ways to make it run on every sheet but I don't want it to do that. Basically, the workbook has a Billing sheet, individual month sheets (not used in this marco) and then individual client sheets. I want this to run on all my client sheets (currently 4 but will be growing). I appreciate any help. Here is the code I have:
Sub PetersBilling()
If ActiveSheet.Name = "Billing" Then

MsgBox ("Please choose another source sheet.")

Else
Dim rSourceName As String
Dim rSourceInvDate As String
Dim rSourcePayDate As String
Dim rSourceDecBill As String
Dim shCurrentPage As String
rSourceName = "='" & ActiveSheet.Name & "'!$C$5"
rSourceInvDate = "='" & ActiveSheet.Name & "'!$Q$5"
rSourcePayDate = "='" & ActiveSheet.Name & "'!$T$5"
rSourceDecBill = "='" & ActiveSheet.Name & "'!$P$21"
Sheets("Billing").Select
Range("B2").Select

Do Until Selection.Value = ""
Selection.Offset(1, 0).Select
Loop

Selection.Value = rSourceName
Selection.Offset(0, 1).Select
Selection.Value = rSourceInvDate
Selection.Offset(0, 1).Select
Selection.Value = rSourcePayDate
Selection.Offset(0, 1).Select
Selection.Value = rSourceDecBill

End If
Next Sh

End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
oops, the "next sh" at the end was left over as part of another solution I was trying and is not part of the orig macro my friend built
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

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