jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
834
I have the following data in columns E and F.

In G via a loop I am trying to populate - I have given a few examples in the right column as to how it should look. This attempt isn't quite working.

Code:
Sub Loop1()


Dim i As Integer
Dim j As Integer


NumberRows = Application.WorksheetFunction.CountA(Columns("E:E"))


For j = 1 To NumberRows


For i = 1 To Cells(1, 6).Value


Cells(j, 7) = (Cells(j, 5) & "&page=" & i & "&count=48")


Next


Next


End Sub

Apples3Apples &page=1&count=48
Pears2Apples &page=2&count=48
Apples2Apples &page=3&count=48
Grapes3Grapes &page=1&count=48
Apples1
Bananas3
Apples1
Pears1

<tbody>
</tbody>

Any help appreciated, thanks!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Can you please explain what you are trying to do, as I cannot see any logic to your example?
 
Upvote 0
Try:
Code:
Sub m1()

    Dim LastRow   As Long
    Dim x         As Long
    Dim y         As Long
    Dim z         As Long: z = 1
    
    LastRow = Cells(Rows.Count, 5).End(xlUp).Row
    
    Application.ScreenUpdating = False
    
    For x = 1 To LastRow
        For y = 1 To Cells(x, 6).Value
            Cells(z, 7).Value = Cells(x, 5).Value & "&page=" & y & "&count=48"
            z = z + 1
        Next y
    Next x
    
    Application.ScreenUpdating = False

End Sub
 
Last edited:
Upvote 0
Try:
Code:
Sub m1()

    Dim LastRow   As Long
    Dim x         As Long
    Dim y         As Long
    Dim z         As Long: z = 1
    
    LastRow = Cells(Rows.Count, 5).End(xlUp).Row
    
    Application.ScreenUpdating = False
    
    For x = 1 To LastRow
        For y = 1 To Cells(x, 6).Value
            Cells(z, 7).Value = Cells(x, 5).Value & "&page=" & y & "&count=48"
            z = z + 1
        Next y
    Next x
    
    Application.ScreenUpdating = False

End Sub

JackDanIce that works thanks a lot!
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,184
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top