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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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