PC Review


Reply
Thread Tools Rate Thread

define a label

 
 
=?Utf-8?B?YW5zd2VyMzM=?=
Guest
Posts: n/a
 
      9th May 2007
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

 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      9th May 2007
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" <(E-Mail Removed)> wrote in message
news:9D34634C-CE1B-4DC5-B04F-(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      9th May 2007
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

labelnamehere:
'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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Tab inside Define Label Gladys Microsoft Word Document Management 2 29th Oct 2009 03:57 PM
Access 2003 Label Report - Text Position On Label Question Dermot Microsoft Access Reports 7 4th Dec 2008 01:06 AM
Word prints label in center of page instead of on select label =?Utf-8?B?R01vbQ==?= Microsoft Word Document Management 1 30th Aug 2006 08:23 PM
How to take the worksheet name as a variable(Label/Define) in a fo =?Utf-8?B?U3ViaW4=?= Microsoft Excel Worksheet Functions 2 14th Mar 2006 12:43 PM
How to change mailing label size in existing label document =?Utf-8?B?R3Jhbm55QW5u?= Microsoft Word Document Management 1 2nd Dec 2004 05:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:58 PM.