0
votes

I have a spreadsheet called "SicknessRecordGraded" which has a varying number of rows.
Columns A - F (1 - 6), have raw content to calculate.
Then from columns I - AG (9 - 33) there are a range of formulas which calculate the information in A - F.
I am preparing a vba macro to auto copy the range of formulas from I - AG into each row where there is content in A - F.
I have been attempting to write the macro as follows. I have the range to copy correct using the .resize function, however I have not figured out how to paste into the correct range.

    Public Sub experiment2()


Dim rw As Long
rw = 3

    ' Select initial sheet to copy from
    Sheets("SicknessRecordGraded").Select


    ' Find the last row of data - xlUp will check from the bottom of the spreadsheet up.
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    ' For loop through each row
    For x = 1 To FinalRow

            Cells(rw, 9).Resize(1, 33).Copy ' Resize from intial range. Columns I - AG.

             NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1 'Continue incrementing through the rows.
            Cells(NextRow, 1).Select ' Find the next row.
            ActiveSheet.Cells(NextRow, "I").PasteSpecial xlPasteAll ' Paste information.
            Sheets("SicknessRecordGraded").Select 'Reselect sheet to copy from. Probably uneccessary.

    Next x
End Sub

I would assume that the line to amend would be

ActiveSheet.Cells(NextRow, 1).PasteSpecial xlPasteAll ' Paste information.

to include another range function.

1
Are you aware that Cells(x, 9).Resize(9, 33) resizes to a range of 9 rows x 33 columns, not a one row range from column 9 to column 33? - Rory
It doesn't appear so. That is useful. - AMorton1989

1 Answers

0
votes

If the range you wish to start the paste in is Cells(NextRow, 1) then you would simply use:

ActiveSheet.Cells(NextRow, 1).PasteSpecial xlPasteAll

or:

ActiveSheet.Paste Cells(NextRow, 1)