Report

Need help going down a line in Excel VBA [Solved]

Ask a question mndude 2Posts Friday January 15, 2016Registration date January 15, 2016 Last seen - Latest answer on Jan 15, 2016 07:19PM
Hello good folks,
Please, I'm trying to write a simple Excel macro that will basically click on hyperlinks within the cells, but I don't know how to have it go down to the next line automatically. Here is what I currently have:
"Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("E4").Select
Application.Wait Now + TimeValue("00:00:20")
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("E5").Select
Application.Wait Now + TimeValue("00:00:20")
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("E6").Select
Application.Wait Now + TimeValue("00:00:20")
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("E7").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("E8").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True"
As there'll be thousands of lines to go down to, I would like to have it just go to the next line without having to write thousands of lines of code like this. How should I type this? Someone mentioned using the For Loop command, but I am so new to this that I would have no idea how to enter that. Please how should I write this?
Thank you in advance for your help with this.
See more 
Helpful
+2
moins plus
A "FOR" loop will do this.

So set a variable to the number of lines, as in:


dim x, t
dim countx, rowletter
dim theactivesheet
rowletter="E"
x=theactivesheet.numberofrows.count
for t = 1 to x
countx=rowletter+x
Range(countx).Select
Application.Wait Now + TimeValue("00:00:20")
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
next


So, there ya go. I must tell ya, I am not here to troubleshoot the above code. The above code is meant as an example of what you are attempting to cut and paste together, as in SCRIPT KIDDIE!

I can only hope that you have learned something, and will continue to explore the world of programming. Once again, this code will not run as published (well not on VBSCRIPT)!

Have FUN!


Add comment

Members get more answers than anonymous users.

Being a member gives you detailed monitoring of your requests.

Being a member gives you additional options.

Not a member yet?

sign-up, it takes less than a minute and it's free!