Macro Fill Down Error

spyldbrat

Board Regular
Joined
May 5, 2002
Messages
211
Office Version
  1. 365
My spreadsheet has a header row on row 4. The macro below is suppose to put a formula on row 5 in columns F and K and fill down to the last row of data. The macro is doing this, but after it adds the formula in F on row 5, it then copies down the HEADER row on row 4, wiping out the formulas. It is doing the same exact thing for column K. Why is this happening?

Sheets("NJN Lic Exp").Select
Dim UsdRws As Long
UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("F5").Select
ActiveCell.Formula2R1C1 = _
"=MID(CELL(""filename"",R[-4]C[-5]),FIND(""]"",CELL(""filename"",R[-4]C[-5]))+1,255)"
Range("f5:f" & UsdRws).FillDown
Range("K5").Select
ActiveCell.FormulaR1C1 = _
"=CONCAT(RC[-3],"": "",R4C9,"":"","" "",RC[-2],"","",R4C10,"":"","" "",RC[-1])"
Range("k5:k" & UsdRws).FillDown
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try it this way
VBA Code:
Sub MM1()
Dim UsdRws As Long
UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("F5:F" & UsdRws).Formula = "=MID(CELL(""filename"",A1),FIND(""]"",CELL(""filename"",A1))+1,255)"
Range("K5:K" & UsdRws).Formula = "=CONCAT(H5,"": "",$I$4,"":"","" "",I5,"","",$J$4,"":"","" "",J5)"
End Sub
 
Upvote 0
Dim UsdRws As Long UsdRws = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row Range("F5:F" & UsdRws).Formula = "=MID(CELL(""filename"",A1),FIND(""]"",CELL(""filename"",A1))+1,255)" Range("K5:K" & UsdRws).Formula = "=CONCAT(H5,"": "",$I$4,"":"","" "",I5,"","",$J$4,"":"","" "",J5)"
It works PERFECTLY!!!!! Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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