if then and go to

m_in_spain

Board Regular
Joined
Sep 28, 2018
Messages
72
Office Version
  1. 365
Platform
  1. Windows
Hi,
My latest question, to me, seems much simpler that what i have previously asked, but i cannot get through it without label not defined errors, endif without this that and the other errors

I need a short piece of code that if the result of a particular cell (AA99) on Sheet33 is 1000001 then go to a particular line of code, otherwise (and the only other number it could be is 1000000) go to a line further down the code and continue from there.

I do not want to use line numbers in the code as these may change as my project grows, i tried using a label of Label1 and Label2, but this errored, i tried DIM label1 as string etc.

As i say i think this must be rather simple, but its floored me!

Help so far from here has been invaluable, please send more!

Thanks In advance
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Maybe:
Code:
Sub Test()
    If Range("A9").Value = 1000001 Then
        GoTo Location1
    Else
        GoTo Location2
    End If
    
Location1:
    MsgBox ("Location1")
    Exit Sub
Location2:
    MsgBox ("Location2")
End Sub
 
Upvote 0
You, Sir, in my eyes, are a genius, and I thank you. Works like a dream, I'm sure it will not be too long until i am stuck again!
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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