Help. Can I bypass a single line from a code

Simon59

New Member
Joined
Oct 23, 2010
Messages
4
I was wondering if anyone can help me with this. (ps I'm new at vb but enjoying it immensly)

Sub AcceptPriceChangesClient1()

Range("c13:v13").Select
Run ("PriceChangesStep1") ' to copy range c13:v13

Sheets("1").Select

Run ("PriceChangesStep2") ' to paste range

MsgBox ("Prices have been updated successfully")

End Sub
I THEN HAVE THE SAME THING FOR CLIENT 2

Sub AcceptPriceChangesClient2()

Range("c13:v13").Select
Run ("PriceChangesStep1") ' to copy range c13:v13

Sheets("2").Select

Run ("PriceChangesStep2") ' to paste

MsgBox ("Prices have been updated successfully")

End Sub
THIS GOES ON FOR SEVERAL CLIENTS.

I then created a button for the below code so that when I so price changes of more than one client, or even of all of them, All Prices are updated.

Sub AcceptPriceChangesClientAll()

Run ("AcceptPriceChangesClient1")
Windows("INVOICES 2011.xlsm").Activate

Run ("AcceptPriceChangesClient2")
Windows("INVOICES 2011.xlsm").Activate
etc.

The problem is that everytime its also running the following

MsgBox ("Prices have been updated successfully")

and I end up pressing <enter> according to the number of clients.

Is there a way out of it.... Is there anything to bypass that particular line, when I run that button to update prices for all clients.

Thanks for any help
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You could use a variable at the top of the module (before any subs) like this

Code:
Public Alerted As Boolean

Sub AcceptPriceChangesClient1()

Range("c13:v13").Select
Run ("PriceChangesStep1") ' to copy range c13:v13

Sheets("1").Select

Run ("PriceChangesStep2") ' to paste range
If Alerted Then Exit Sub
MsgBox ("Prices have been updated successfully")
Alerted = True
End Sub
 
Upvote 0
Thanks MR. VoG

Didn't work but it's probably me since I'm so inexperienced. Still I appreciate your help immensly.
I managed to solve it by going around it and repeating the task.

Once again thanks.
 
Upvote 0

Forum statistics

Threads
1,213,514
Messages
6,114,078
Members
448,547
Latest member
arndtea

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