label not defined

0 Agios

Well-known Member
Joined
Feb 22, 2004
Messages
570
Office Version
  1. 365
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim str_folder As String


If Range("B5").Select Then GoTo 100 Else GoTo 200
200
If Range("B6").Select Then GoTo 300 Else GoTo 400
400
If Range("B7").Select Then GoTo 500 Else GoTo 600
600
If Range("B8").Select Then GoTo 700 Else GoTo 800
800
If Range("B9").Select Then GoTo 900 Else GoTo 1000
1000
If Range("B10").Select Then GoTo 1100 Else GoTo 1200
1100 MsgBox "fjfjfjjf"

1200
End Sub



100
str_folder = "Z:\1-PRE-CONSTRUCTION\2-2021 BIDS\1_CURRENT BIDS\" & Range("C5").Text & "\1-Estimating\3-Bid Drawings\1-Drawings"
Call Shell("explorer.exe " & str_folder, vbNormalFocus)
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
That is because you do not have 300, 500 ,700, or 900 defined anywhere in your code (at least not anywhere in the code that you posted).
You are telling to go somewhere that does not exist in your code.

Note, it is highly advised not to use a lot of GoTo commands in Excel VBA. It is common in some older programming languages, but not so much in Excel.
See here: GoTo statement (VBA).
 
Upvote 0
When I see code like this:
If Range("B5").Select Then GoTo 100 Else GoTo 200
200

I think of code written years ago when Goto 100 meant Goto line 100 of the code.
I see you do not show what version of Excel your using.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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