Excel VBA trying to loop through rows in a named range


When you see my file, you will know right away that I am clueless when it comes to using VBA in Excel.

I created a macro that goes out to a website and looks up a small amount of data for one golfer. Now I am trying to figure out how to do this for all golfers in a table. If I could figure out how to loop through all users I would then have to figure out to have the data pasted below the previous golfers data. The data for each golfer should span 3 rows. So, I need to be able to go down 3 or 4 rows before pasting the next golfer.

Thanks, Dale

Dale LoganConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
I haven't looked at your code yet but to loop through a named range

Dim rngRow As Range
For Each rngRow In Range("MyNamedRange").Rows
    Debug.Print rngRow

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale LoganConsultantAuthor Commented:
Ok, I think I've added that part correctly, but can't be sure until I get everything else fixed.

Each time the loop runs I need a url inserted. The only thing different each time is the value in the third column of the named range needs to be inserted in the middle.

Here's how I am trying to do that:

Dim String1 As String
Dim String2 As String

String1 = "URL;http://widgets.ghin.com/HandicapLookupResults.aspx?entry=1&dynamic=&small=0&css=default&ghinno="
String2 = "hidename=0&showmsg=0&showheader=1&showtabheader=0&combinehieff=0&showheadertext=1&showfootertext=1&tab=2"


Open in new window

Martin LissOlder than dirtCommented:
That should work. (I know the rngRow.Columns(3) part is correct)
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Dale LoganConsultantAuthor Commented:
I must not be putting the url string together correctly. I get the attached error message in the attached section.
Martin LissOlder than dirtCommented:
There shouldn't be quotes around String1 & rngRow.Columns(3).Value & String2.
Dale LoganConsultantAuthor Commented:
Wow. It looks like we are really close. The only thing left to figure out is to have the loop drop down 3 cells each time through. Currently it is overwriting the previous loops results each time. I have a line in there that says: Destination:=Range("$A$1")). How would I make it drop down 3 cells each time?
Dale LoganConsultantAuthor Commented:
Got it figured out. Thanks so much for your help.
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.