2 sheets with different finalrow variables

ShaunD30

Board Regular
Joined
Jun 19, 2008
Messages
172
Ok...Trying to get a "do until" loop.

I have

Finalrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
Finalrow2 = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row

I need my "Do until" loop to run until the activecell in sheet1 =finalrow

I tried "Do until activecell.row=Finalrow", however that didn't work because it ended my macro too soon.

I tried "Do until sheets("Sheet1").Activecell.row=Finalrow
But it won't accept that.

any idea on how I need to word this so it works?

Shaun
 
Perhaps

Code:
Sub GetData()
Dim FinalRow As Long, Finalrow2 As Long, FinalRow3  As Long, i As Long, j As Long
Dim Curzip As Variant
With Sheets("Sheet1")
    FinalRow = .Cells(Rows.Count, 1).End(xlUp).Row
    Finalrow2 = Sheets("Sheet4").Cells(Rows.Count, 1).End(xlUp).Row
    For j = 2 To FinalRow
        Curzip = .Range("B" & j).Value
        For i = 2 To Finalrow2
            If Sheets("Sheet4").Cells(i, 7).Value = Curzip Then
                FinalRow3 = Sheets("Sheet3").Range("A1" & Rows.Count).End(xlUp).Row
                Sheets("Sheet4").Cells(i, 2).Copy Destination:=Sheets("Sheet3").Range("A" & FinalRow3 +1)
            End If
        Next i
    Next j
End With
End Sub
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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