Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default define a label

It may sound basics, put I need help to define a label...

I try the following codes and it alwas get an error of label not define.

Dim ws As Worksheet
Set ws = Worksheets("data2")
If WorksheetFunction.Count(ws.Cells) = 0 Then GoTo labelNameHere

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default define a label

from the help file:

GoTo Statement Example
This example uses the GoTo statement to branch to line labels within a
procedure.

Sub GotoStatementDemo()
Dim Number, MyString
Number = 1 ' Initialize variable.
' Evaluate Number and branch to appropriate label.
If Number = 1 Then GoTo Line1 Else GoTo Line2

Line1:
MyString = "Number equals 1"
GoTo LastLine ' Go to LastLine.
Line2:
' The following statement never gets executed.
MyString = "Number equals 2"
LastLine:
Debug.Print MyString ' Print "Number equals 1" in
' the Immediate window.
End Sub

--


Gary


"answer33" wrote in message
...
It may sound basics, put I need help to define a label...

I try the following codes and it alwas get an error of label not define.

Dim ws As Worksheet
Set ws = Worksheets("data2")
If WorksheetFunction.Count(ws.Cells) = 0 Then GoTo labelNameHere



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default define a label

You have to have some line in your code that looks like a label:


Dim ws As Worksheet
Set ws = Worksheets("data2")
If WorksheetFunction.Count(ws.Cells) = 0 Then GoTo labelNameHere
'do some stuff

labelnamehe
'do different stuff

======
But I think most would say that using labels may not be the best way to approach
it.

Can't you just write your if statement something like:

Dim ws As Worksheet
Set ws = Worksheets("data2")
If WorksheetFunction.Count(ws.Cells) = 0 Then
'do nothing
else
'do some stuff
end if

'do different stuff



answer33 wrote:

It may sound basics, put I need help to define a label...

I try the following codes and it alwas get an error of label not define.

Dim ws As Worksheet
Set ws = Worksheets("data2")
If WorksheetFunction.Count(ws.Cells) = 0 Then GoTo labelNameHere


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the font for part of an axis label, not the whole label. amy45 Charts and Charting in Excel 2 April 5th 23 01:11 PM
How to rezize data label box in pie charts (label wraps to two lin rolliedogg Charts and Charting in Excel 1 October 18th 06 08:17 PM
How to take the worksheet name as a variable(Label/Define) in a fo Subin Excel Worksheet Functions 2 March 14th 06 12:43 PM
Using Name Label to try to define linked cell John Links and Linking in Excel 5 December 4th 04 09:12 AM
add text to label (label from forms toolbar) Rob Bovey Excel Programming 0 September 5th 03 09:46 PM


All times are GMT +1. The time now is 03:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"