View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default use a variable for a worksheet name in a formula

you could use vb and use something like this:

Sub test()
Dim ws As Worksheet
Set ws = Worksheets(1)
Range("B2").Formula = "=INDIRECT(""" & "'" & ws.Name & "'!B1""" & ")"
End Sub

--


Gary


"caroline" wrote in message
...
Hello,
I would like to use a formula with variable to access worksheets
(Like the VBA Worksheets(Range("a1").Value). I do not want to use VBA
because I need the user to see the formula.

My worksheets are named 'Input','Definition' . . .
I have found this formula in previous answers
=INDIRECT("'sheet (" & A1 & ")'!B1")
but this works only if the worksheets are named 'Sheet (1)','Sheet (2)'

Any idea?
Thanks!


--
caroline