If then statement Structure in Code - macro does not execute

jwpardo

New Member
Joined
Dec 17, 2003
Messages
22
If have a macro with an if then else structure. I will show it below, however, the macro skips over the if then else stmt. Also, no error shows up before or after the execution in the module.

Any thoughts.
Thanks
James

(PS: framestyle and hoiststyle are names of cells in the only open worksheet.)

Sub hoist_option_2button()
'
' hoist_option_2button Macro
' hoist option 2 logic

' Range("whatnow").select
Range("whatnow").Value = 9

' If range("framestyle").value= 2 Then range("hoiststyle").value= 9 Else range("hoiststyle").value=2


'
End Sub
[/quote][/code]
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
Re: If then statement Structure in Code - macro does not exe

Well, that portion of the macro is commented out (the single quote at the beginning), that's probably why...
 

NateO

Legend
Joined
Feb 17, 2002
Messages
9,700
Re: If then statement Structure in Code - macro does not exe

Try removing the ' :)
 

bjwillingham

Active Member
Joined
Jun 17, 2003
Messages
287
Re: If then statement Structure in Code - macro does not exe

I hate it when that happens. :oops:
 

jwpardo

New Member
Joined
Dec 17, 2003
Messages
22
Re: If then statement Structure in Code - macro does not exe

Thank you all. Removing the ' solved my problem.
james
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,968
Messages
5,856,579
Members
431,820
Latest member
martel_9

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
Top