-
Simple Code - Help
I Need a simple script like this one to do this in excel .... but with a loop or something from row 17 to row 100 and i dont want to repeat the same line 80 times. I know its simple but i dont know : (
Code:
Sub Macro1()
Range("H17").Select
Selection.Hyperlinks.Add Anchor:=Selection, Address:=Range("AZ17")
Range("H18").Select
Selection.Hyperlinks.Add Anchor:=Selection, Address:=Range("AZ18")
Range("H19").Select
Selection.Hyperlinks.Add Anchor:=Selection, Address:=Range("AZ19")
End Sub
Thanks !!!!!!
:)
Regards
Francisco
-
Re: Simple Code - Help
Freehand, but should be fine
Code:
Sub Macro1()
Dim myRange as String, Ctr as Integer
For Ctr=17 to 100 ' or whatever
myRange="H" & val(ctr) ' Build Value
Range(myRange).Select ' Use Value here!
Selection.Hyperlinks.Add Anchor:=Selection, Address:=Range("AZ17")
Next Ctr
End Sub
-
Re: Simple Code - Help
Looks good. Except for Address:Range("AZ17")
Shouldn't that be Address:Range("AZ"&CSTr(ctr))
also myRange="H"&Cstr(ctr) not &Val(ctr)
Val is not resulting in a string, unless VBA is completely different to VB.
-
Re: Simple Code - Help
Cstr() adds a leading space, as I recall. I figured the compiler would help out there
-
Re: Simple Code - Help
If I remember correctly CStr() does not use a leading space STR() adds one if the number is positive.
-
Re: Simple Code - Help
That's correct. New it was close...
-
Re: Simple Code - Help
instead of range user cells(row,col).
Here you provide integer as row and column.
eg : for B you use 2, c 3, etc