• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to set which Macro should be run base on Text or val on A1 to D1?

Dear All Experts,


Subject:- How to set which Macro should be run base on Text or val on A1 to D1?

if A1 to D1 have some value then run this macro other wise run this macro..

for example if column A1 to D1 have
A1=BUY , B1=CHNL, C1=TYPE, D1=ORD.NO, then particular macro should be run otherwise another macro should be run.

how & where to put this check in macro?

hope there are some solution found on this site..

Regards,

Chirag Raval
 
Hi !

As at very beginner level : just use a so simple & common If statement
combined with And operators ‼
At top of main macro if you really need such sub level procedures.

Another way : by an easy concatenation worksheet formula within an If

Other way : Select Case statement
(to see in VBA inner help and samples in threads of this forum) …
 
Dear Sir @Marc L,

Thank you very much for valuable reply..
as per your suggestion,

"As at very beginner level : just use a so simple & common If statement
combined with And operators ‼ At top of main macro if you really need such sub level procedures."

my requirement is very simple.. hope help from your side.

if example as a solution found from your side also for as select case, then
that's call universal solution find for this thread.

hope you co-operation..

Regards,
Chirag Raval
 
See example in attached.
Code:
Sub blah()
If Range("A1") = "BUY" And Range("B1") = "CHNL" And Range("C1") = "TYPE" And Range("D1") = "ORD.NO" Then
  ThisMacro
Else
  ThatMacro
End If
End Sub

Sub ThisMacro()
MsgBox "running ThisMacro"
End Sub

Sub ThatMacro()
MsgBox "running ThatMacro"
End Sub
 

Attachments

  • Cjandoo36224.xlsm
    17.3 KB · Views: 3
Last edited:
my requirement is very simple.. hope help from your side.
My advice was clear : as it's at beginner level, you can achieve it yourself
just by reading VBA inner help and even before creating this thread
or doing a search within this forum …
So no sample from my side when it already exists in VBA inner help.

I can reveal a tip when I see an effort of the original poster
attempting to create himself its own code, not when he ask to do his job …

As here it is a VBA forum for people who write their own code,
willing to learn how to …
This is not a forum « create my project for my job ».

If at least you read your own past threads, you already had the solution !

So following Confucius way I prefer to
« show you how to fish and not to bring you a fish every day » …

Now this thread is done with the starter offered by p45cal.
 
Dear Sir @Marc L ,

Yes you are absolutely right ..I feel also something like
Why I can't do that? & why I not little try before posting ?
Though i can start from something or study for something
But actually due to VBA is vast & have powerful inviroment
With many-many logical twisting but strongly working
Programming concepts , I feel (or in little fear) that if startup goes in to trap
In limited criteria then I can miss some more powefull & created on widely
Covered concepts for "Can be do Same thing This Way"

I really like your startup answewd post that pointing towards ' You can dodo that
This many types of ways" I appreciated it..

I also feel sorry & accept my mistake that though you pointing
Towards ways for try , I wanted code from you..
I know that happened in past..sorry for that..
& thank you for motivate.

I hope from myself that first try , & then
Create thread with my try..

Regards,

Chirag Raval
 
Back
Top