VB Nested IF

rmfrase

Board Regular
Joined
Jul 6, 2006
Messages
132
Office Version
  1. 365
Platform
  1. Windows
Based on the results, I need to have the VM Macro jump to a specified section. but I'm having trouble on this and need assistance if possible.

For i = 2 To lastrow
'get values from cells
Cells(i, Ext.Column).Select
prop = Cells(i, Ext.Column)

Cells(i, GSE.Column).Select
Gcode = Cells(i, G.Column)

Cells(i, prop.Column).Select
PType = Cells(i, prop.Column)

'now figure out where to go (and where I'm having trouble as it does not go where I need it to go based on the IF statement results.
'if true on all 3
if prop = "Int", Gcode = "other", PType = "SFD" then gosub INTSFD
if prop = "Ext", Gcode = "other", PType = "Other" then gosub EXTSFD
if prop = "Int", Gcode = "FN", PType = "SFD" then gosub INTFNSFD

'loop it
Loop:
next i

INTSFD:
' I'll do something here
return

EXTSFD:
' I'll do something here
return

INTFNSFD:
' I'll do something here
return
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Maybe something like this

Code:
For i = 2 To lastrow
'get values from cells
prop = Cells(i, Ext.Column).Value

Gcode = Cells(i, G.Column).Value

PType = Cells(i, prop.Column).Value

'now figure out where to go (and where I'm having trouble as it does not go where I need it to go based on the IF statement results.
'if true on all 3
If prop = "Int" And Gcode = "other" And PType = "SFD" Then GoTo INTSFD
 
Upvote 0
I just tried that but it did not work.

While running the Macro, it went thru each line but did not "Goto" the destination as expected it simply passed thru it as if nothing matched. But the Values were as expected. So I'm not sure why it didn't work.
 
Upvote 0
I found the issue - Interior wasn't INTERIOR (upper case)

Thank you for your help.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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