VBA Use Row Count of Data above to Copy Row of Formulas in a Row below across Columns down for Row Count

garybravo

New Member
Joined
Feb 27, 2022
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Hi All, am new to the Board, hoping someone may help me please.

I have written VBA here and there, and have automated a journal creation and export to csv, but this below prob for the life of me, can't get it to do what I want.

Image of an example "Data" Sheet attached, based on the number of rows with data counted between C3:C16 (in this example 11), I want to copy the row of formulas in Row 18 across the columns down from Row 19 for the number of Rows counted between C3:C16. I have tried the following simple code, at first appeared to work, but when reran it, it every time copies the formulas all the way to the last row.

Sub test()

nrows = Sheets("Data").Cells(Rows.Count, 3).End(xlUp).Row
Sheets("Data").Rows("18:18").Copy
Sheets("Data").Rows("19:19" & nrows).Select
ActiveSheet.Paste

End Sub

I have tried various other variations, as well as trying to build a CountIf into the code, to no avail.

Would appreciate some assistance. As I say, my VBA is basic at best.

Cheers

Gary
 

Attachments

  • Excel Com.JPG
    Excel Com.JPG
    90.5 KB · Views: 12

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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