View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default assigning worksheet variable

Just to add to Bob's reply...

One very nice reason to use the variable ws (and to declare it as a worksheet)
is that you'll get VBE's intellisense while you're writing the code.



Bob Phillips wrote:

Simon,

There is only one activesheet in a workbook, so you can get it simply by

Set ws = Activesheet

but you could just as easily use use ACtivesheet in your code directly.

You may be thinking of selected sheets, which is accessed like

For Each ws In Activewindow.SelectedSheets
...
Next ws

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Simon Shaw" wrote in message
...
I want to set the variable ws similar to the For statement, but I want to

set it for just the current active sheet.

Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets

please help this is not working:

ws = ActiveSheets


--

Dave Peterson