If function understanding

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Sipeneco
Newbie
Posts: 6
Joined: Thu Aug 31, 2023 10:43 pm

If function understanding

Post by Sipeneco » Thu Aug 31, 2023 10:49 pm

Hi, I'm new to my Macro scheduler and I need to use the function if. I need the function to check two values. that failures will come from a website and excel and I need to check if they are the same. if they are I want the function to stop the macro and if they are not I needed to continue the macro. Can you give me example

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: If function understanding

Post by Dorian (MJT support) » Fri Sep 01, 2023 12:51 pm

To compare two variables and exit the script if they are not the same, you'd do something like this :

Code: Select all

if>%variable1%<>%variable2%
  exit
endif
You can see an in-depth description of IF here.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: If function understanding

Post by Grovkillen » Fri Sep 01, 2023 3:51 pm

And this is also valid:

Code: Select all

ifnot>%variable1%=%variable2%
  exit
endif 
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: If function understanding

Post by Dorian (MJT support) » Fri Sep 01, 2023 5:02 pm

You know.... I don't think I've ever used that in the 25 years I've been using MS (IfNot probably hasn't existed for 25 years)...

In fact it slipped my mind that it even existed.
Yes, we have a Custom Scripting Service. Message me or go here

Sipeneco
Newbie
Posts: 6
Joined: Thu Aug 31, 2023 10:43 pm

Re: If function understanding

Post by Sipeneco » Fri Sep 01, 2023 7:22 pm

ok, how do I import the external data to the variables/code so we can control it.

Imagine I want scrape data from a website but I need to know if that was already been scraped. I have list it all the links that had been scraped and I want compare the last link of list with link I am trying to scrape.

The examples provided in your library, already got the value of the variable in the code...

Did I explain the problem successfully

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: If function understanding

Post by Dorian (MJT support) » Sat Sep 02, 2023 8:29 am

What you want to do is quite complex for a beginner. You'll need to master and fully understand the techniques linked below before you should even think about putting it all together into something resembling your "end product". Learn and test each stage/element. Make sure you can walk before you try to run.

Reading from Excel.

For "scraping" pages
Yes, we have a Custom Scripting Service. Message me or go here

Sipeneco
Newbie
Posts: 6
Joined: Thu Aug 31, 2023 10:43 pm

Re: If function understanding

Post by Sipeneco » Sat Sep 02, 2023 2:57 pm

I just need the function to bring the data from the "selected copy"(CTRL + C) to the code.. so I can build the condition for the function IF.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: If function understanding

Post by Dorian (MJT support) » Sat Sep 02, 2023 3:38 pm

Yes, we have a Custom Scripting Service. Message me or go here

Sipeneco
Newbie
Posts: 6
Joined: Thu Aug 31, 2023 10:43 pm

Re: If function understanding

Post by Sipeneco » Sat Sep 02, 2023 11:14 pm

special thanks!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts