ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to refer variable while assigning string value? (https://www.excelbanter.com/excel-programming/369561-how-refer-variable-while-assigning-string-value.html)

[email protected]

How to refer variable while assigning string value?
 
--------
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?


Xcelion

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?




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com