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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,651
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
 

Simon59

New Member
Joined
Oct 23, 2010
Messages
4
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.
 

Forum statistics

Threads
1,081,657
Messages
5,360,291
Members
400,580
Latest member
Drexl88

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top