-
August 4th, 2009, 02:29 PM
#1
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
Last edited by Frlecube; August 4th, 2009 at 02:31 PM.
-
August 4th, 2009, 03:00 PM
#2
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
-
August 4th, 2009, 05:00 PM
#3
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.
-
August 4th, 2009, 09:05 PM
#4
Re: Simple Code - Help
Cstr() adds a leading space, as I recall. I figured the compiler would help out there
-
August 4th, 2009, 11:23 PM
#5
Re: Simple Code - Help
If I remember correctly CStr() does not use a leading space STR() adds one if the number is positive.
-
August 5th, 2009, 12:11 AM
#6
Re: Simple Code - Help
That's correct. New it was close...
-
August 7th, 2009, 05:36 AM
#7
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|