Copy and Paste 'X' rows

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
I'm currently using the below code to add the formula in each cell. Depending on the number of rows.
It's very slow (Range("aa2").Value returns 1060) which means 1k rows. I was thinking of doing copy and paste to speed up. But I do not want to fill the whole column U (Column 13) with the formula. Is there anyway to set the max to copy to?
like r2:rX

where X is Range("aa2").Value?

Code:
Private Sub CommandButton1_Click()
    Dim nDb As Integer
    intRow = 2
    Range("aa2").Value = "=COUNTA(A:A)-1"
    nDb = Range("aa2").Value
 
       Do While nDb > intRow
                               Var = "=IF(RC2=""Positive Adjmt."",+RC13,IF(RC2=""Negative Adjmt."",-RC13,""Invalid""))"
                ActiveSheet.Range("u" & intRow).End(xlUp).Offset(1, 0).Resize(, 1) = Var
                'Worksheets("nvT").Cells(intRow2, 4).Resize(, cpro).Value = qty
 
        intRow = intRow + 1
        Loop 'end of do-while
End Sub
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,215,453
Messages
6,124,929
Members
449,195
Latest member
Stevenciu

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