View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Sheetname variable

Garry,

Try this

Private Sub setar(ArgValue As Integer)
Worksheets("Sheet" & ArgValue).Name = "NewName"
End Sub


--

HTH

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

"Garry Jones" wrote in message
...
I would like to name a worksheet, but the worksheet that shall be named
is dependant upon which button is pressed.

What I want from this code is is

Sheet1.Name = "NewName"

(ie if command button 1 is pressed)

What am I missing here?
____________________________________________

Private Sub CommandButton1_Click()
setar (1)
'when Command Button 1 is clicked it sends the number 1 as a variable to
the code
End Sub
____________________________________________

Private Sub setar(ArgValue as Integer)
("Sheet" & ArgValue).Name = "NewName"
'Missing something here
End Sub
____________________________________________

I am working with Swedish Excel, in Swedish the worksheet control name
is known as "blad", I seem to remember it was "sheet" in English, if I
am wrong my posting may be confusing. Maybe its "worksheet", anyway,
that doesn't really matter, I just need the code and then I can write
"blad" anyway.


Garry Jones