What is the VB code to do an IF THEN macro?

slack7639

Board Regular
Joined
Apr 19, 2016
Messages
65
AI banned? I asked Bing Chat about this, and with some slight modifications, I got it to work! Here's what I asked:

Q: Using VBA 7.0, what is the code for a macro that 1.) Checks to see if Firefox is open, 2.) If Firefox is open, then stop, 3.) If Firefox is not open, open Firefox, and then stop

A: This code uses Windows Management Instrumentation (WMI) to query for processes running on the computer. It sets the process name to check for as “firefox.exe” and the computer name to check on as “.” (local computer). It then queries for processes with that name and checks if any are running. If Firefox is not running, it starts it up using the objShell.Run method1.

. . . Please see Screenshots on imgur . . .
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
AI banned?
Yes, as is was giving incorrect answers (including inventing Excel constants that don't exist) that people were posting without testing or amending, happy it worked for you in this instance but it doesn't always.

I am sure the Admin will review it's use if it improves but as it stands it was causing too many issues in posts for them to allow it's use.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,935
Messages
6,175,493
Members
452,649
Latest member
mr_bhavesh

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