Macro Won't Fill Down Properly

Jett Midknight

Board Regular
Joined
Jan 8, 2014
Messages
110
Hello, I am having a problem with my macro filling down the data properly. I have a table wit headers set up. My macro selects two cells in the first row, and tries to copy it down into the other rows of the table. Instead what happens, the macro copies down the table headers into the two cells that are selected. Here is my code.

Range("I3").Select
ActiveCell.FormulaR1C1 = "Order Filled"
Range("J3").Select
ActiveCell.FormulaR1C1 = "Order FIlled"
Range("I3:J3").Select
Selection.FillDown

Any ideas how to fix this?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
The .FillDown needs a Destination, I believe.

however, I prefer to do it this way, by counting the number of rows that you want to copy down to, storing the number in a variable, and use that variable later. gives a lot of flexibility for a "copy down" macro when you have a varying amount of rows.

i presume that column A:H are are a full table; so i'm just counting the row numbers of column H in the code. could also count column 1 (or A), or any column in your table that has non-blank values.

note, you don't need to select first, you can simply put the .Formula... right after the Range.

i presum that the "order filled" is just a placeholder, and you have an actual formula in there?

Code:
Sub test()
Dim nrows As Long
nrows = Cells(Rows.Count, "H").End(xlUp).Row


Range("I3").FormulaR1C1 = "Order Filled"
Range("J3").FormulaR1C1 = "Order Filled"
Range("I3:J3").Copy Range("I3:J" & nrows)


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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