Excel VBA steps in a loop to move down X number of cells before pasting

I've got everything in my loop working correctly except for having it move down 5 cells before pasting some data. All of my pasted data will contain 4 rows. So, my loop is currently pasting the data right over the top of the data previously pasted. This all was originally created from a macro, so you may see that I am not very proficient with VBA. Thanks for any help you can offer.

Sub Macro2()

Dim rngRow As Range
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"

    Sheets("Output").Select
    Range("A1").Select

For Each rngRow In Range("Players").Rows

    With ActiveSheet.QueryTables.Add(Connection:= _
        String1 & rngRow.Columns(3).Value & String2 _
        , Destination:=Range("$A$1").Offset(5, 0))
        .Name = test
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlOverwriteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = """ctl00_bodyMP_tblTopInfo"",""ctl00_bodyMP_grdClubs"""
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False

    End With
    
Next
    
End Sub

Open in new window

Dale LoganConsultantAsked:
Who is Participating?

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

x
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.

[ fanpages ]IT Services ConsultantCommented:
Hi,

Obviously I cannot test the code, as I do not have your environment to work with, but this should produce what you need...

Sub Macro2()

Dim objCell As Range ' *** ADDED
Dim rngRow As Range
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"

    Sheets("Output").Select
    Range("A1").Select

  Set objCell = [A1] ' *** ADDED

For Each rngRow In Range("Players").Rows

    With ActiveSheet.QueryTables.Add(Connection:= _
        String1 & rngRow.Columns(3).Value & String2 _
        , Destination:=objCell)
        .Name = test
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlOverwriteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = """ctl00_bodyMP_tblTopInfo"",""ctl00_bodyMP_grdClubs"""
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False

    End With
   
  Set objCell = objCell.Offset(5&) ' *** ADDED

Next
   
  Set objCell = Nothing ' *** ADDED

End Sub

PS. Is the variable (or constant) "test" set elsewhere in your code?

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:
PS. Is the variable (or constant) "test" set elsewhere in your code?

No. I forgot that I changed that. It was originally just the long string of text that ends up being the url. Will that cause a problem? It was running just fine.

I will now make the changes you suggest and let you know. Thanks.
Dale LoganConsultantAuthor Commented:
That's awesome. It worked flawlessly.
[ fanpages ]IT Services ConsultantCommented:
You're welcome.

If test is a string variable that contains the required address (URL), & it is working then, no, it will not cause a problem.

However, if you wish, please post your code as it is running (after all your changes), & it can be re-reviewed.
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.