Fill Down Macro Not Working

spyldbrat

Board Regular
Joined
May 5, 2002
Messages
211
Office Version
  1. 365
I have a fill down to copy data to the last row of data. Currently, my spreadsheet has 437 rows of data. Data exists in A, B, C, D, E, F. For some reason, the macro is stopping at row 393. I checked rows 394 and beyond in column G and all columns are blank. Any idea as to why this is happening?

The DIM USDRWS....etc is in an earlier part of the macro so I don't have it listed above the portion of the macro I have included.
Dim UsdRws As Long
UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row



Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]&TEXT(RC[-1],"" MM/DD/YY"")"
Range("g2:g" & UsdRws).FillDown
 

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
What is the value of UsdRws when you get to the filldown section of code?
 
Upvote 0
is this what your looking for?

Dim UsdRws As Long
UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
 
Upvote 0
When the code gets to this line
VBA Code:
 Range("g2:g" & UsdRws).FillDown
what is the value stored in the UsdRws variable?
 
Upvote 0
Add this msgbox as shown
VBA Code:
Range("G2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]&TEXT(RC[-1],"" MM/DD/YY"")"
MsgBox UsdRws
Range("g2:g" & UsdRws).FillDown
then run the code, what does the message box say?
 
Upvote 0
So now I am running the macro and it's bringing the data down to row 785? Again, my last row of data is 437....here are the messages I got when I ran you VBA.


1601577281961.png


1601577312202.png


1601577346776.png
 
Upvote 0
How about something like this instead?
VBA Code:
    Dim lr As Long
'   Find last row with data in column F
    lr = Cells(Rows.Count, "F").End(xlUp).Row
'   Populate all cells of columnG with formula
    Range("G2:G" & lr).FormulaR1C1 = "=RC[-2]&TEXT(RC[-1],"" MM/DD/YY"")"
 
Upvote 0
You are welcome.
Glad we were able to help.

One thing to note there. If you want to apply the same formula to all the cells, it isn't necessary to use Fill Down. You can apply the formula to the whole range at once, like I did in the last line of the code I posted. It also helps make the code a little shorter.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,178
Members
448,871
Latest member
hengshankouniuniu

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