View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
external usenet poster
 
Posts: 21
Default using VBA to populate a hyperlink field

I have a spreadsheet that contains a column of six-digit numbers, and I
would like to use VBA to create a second column of hyperlinks using the
values in the first column. For example, if the first three records in the
first column consist of the following numbers,

124879
126978
198790

I would like to use VBA to populate the second column where the hyperlink
"Text to Display" would be the six digit number, and the hyperlink "Address"
would be a concatenation of a constant string and that number:

"M:\Projects\" & 124879 & "\"
"M:\Projects\" & 126978 & "\"
"M:\Projects\" & 198790 & "\"

I realize that if I were simply trying to copy a modified version of one
column into another I would use something along the lines of:

For k = 1 to n
Worksheets("Sheet1").Cells(k, 1).Copy
Worksheets("Sheet1").Cells(k, 2).PasteSpecial Paste:=xlValues
Next k

But in this case, I'm trying to create a column of hyperlinks that require
two different values for each cell - the "Text to Display" and the
"Address."

How can I use VBA to create this column of hyperlinks?

Thanks in advance,

Paul