Cannot get macro to skip onto next macro after condition met

Melbobs

New Member
Joined
Jul 6, 2018
Messages
3
Hi

I am super new to VBA so please treat me as dumb.

I have a macro that has an IF statement in it. Basically it is referencing a cell, and ifthat cell is blank, I’d like it to go on to run the next macro. Previously the code said ‘End Sub’ but Irealised that was overriding the instruction to proceed with the next macro.

There must be a very simple answer to this but I have triedeverything. I even tried putting Elsestatements in.

Basically I need the code below to instruct (per the belowsheet and cell references):
Check to see if CA2 is blank
If so, then I want it to immediately go to Application.run “Fcopydown”
If CA2 is populated I want it to copy the value to C3001 inSheet1, then move down to the next block of code in the macro

Sheets("qryCC_PostOffice").Select
Range("CA2").Select
If Range("CA2") = "" Then Exit Sub
Selection.Copy
Sheets("Sheet1").Select
Range("C3001").Select
ActiveSheet.Paste

Please help as it's driving me mad

M
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Welcome to the Board!

You say "move on to the next macro", which implies that you have multiple macros.
Can you post the VBA code for all your macros, and the procedure that is calling both of them?
 
Upvote 0
Welcome to the Board!

You say "move on to the next macro", which implies that you have multiple macros.
Can you post the VBA code for all your macros, and the procedure that is calling both of them?

Hi. Thanks for thewelcome. Sorry I can’t paste them all itwould take up too much screen space.
They are just simple steps that basically need to say if X(in this case CA2) is NOT populated proceed to the next macro via theApplication.Run function, if X IS populated then it needs to proceed to thenext step within the current macro
Does that help?
 
Upvote 0
Typically, you would just have one "main" controlling macro that calls all the other macros like this:
Code:
Sub Main()
    Call Macro1
    Call Macro2
    Call Macro3
End Sub
If you do that, it will run Macro1, then when finished, it will proceed to Macro2, and when finished with that it will proceed to run Macro3.
You can add IF blocks around those macro calls if you only want to run some based on certain conditions.
 
Last edited:
Upvote 0
In your first post you said:
I am super new to VBA

Maybe you would like to tell us what your ultimate goal is.

There is normally no reason to need numerous Macros to perform a task.
As being new to Vba you may think that is needed when it really is not
 
Upvote 0
Typically, you would just have one "main" controlling macro that calls all the other macros like this:
Code:
Sub Main()
    Call Macro1
    Call Macro2
    Call Macro3
End Sub
If you do that, it will run Macro1, then when finished, it will proceed to Macro2, and when finished with that it will proceed to run Macro3.
You can add IF blocks around those macro calls if you only want to run some based on certain conditions.

Utter genius
 
Upvote 0

Forum statistics

Threads
1,215,490
Messages
6,125,094
Members
449,205
Latest member
ralemanygarcia

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