View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Xcelion Xcelion is offline
external usenet poster
 
Posts: 39
Default How to refer variable while assigning string value?

Hi

Please use like this
"Folder/Aprofiles_" & CStr(counter) & ".txt"

you missed one &

Thanks
Xcelion





" wrote:

--------
Dim counter As Integer
counter = 1
For Each linkcell In Sheets("My report").Range("B63:B106")
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"Folder/Aprofiles_" & CStr(counter) ".txt",
TextToDisplay:="Aprofiles__" &CStr(counter) ".txt"
counter = counter + 1
Next linkcell
End Sub
--------

The files available under the 'Folder' are as follows:
Aprofiles_1.txt
Aprofiles_2.txt
Aprofiles_3.txt
...............

I want to create the links to each of them in each of the cells in the
range "B63:B106".
The assignment of "Folder/Aprofiles_" & CStr(counter) ".txt" does not
work. How exactly I can refer a variable while assigning the string
value?