FillDown method of range class failed

reubanrao93

New Member
Joined
Dec 7, 2020
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,

I'm trying to run this code but currently am stuck with "Run-Time-error '1004" FillDown method of range class failed" during debug. Is there something I'm missing here?

Sub PastFormula()
Dim LRw As Long
Sheets("Sheet1").Range("S:S").Select
ActiveCell.Formula = "=MID(L2,(LEN(L2)-(LEN(LEFT(L2,LEN(L2)-SEARCH(""ENO="",L2)))-4)),((LEN(LEFT(L2,LEN(L2)-SEARCH(""ENO="",L2)))-4)-(LEN(LEFT(L2,LEN(L2)-SEARCH("",SUB"",L2))))))"
LRw = Range("L" & Rows.Count).End(xlUp).Row

Range(ActiveCell, Cells(LRw, ActiveCell.Column)).FillDown

End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
48,580
Office Version
  1. 365
Platform
  1. Windows
When you get the error, click Debug and hover over the variable name LRw and see what the pop-up says
 

Tegg

New Member
Joined
Nov 18, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi

This code won't run if column L is empty
You also needed to add '.address. in Range()
Hopefully, this code should help

VBA Code:
Sub PastFormula()
Dim LRw As Long
Sheets("Sheet1").Range("S:S").Select
ActiveCell.Formula = "=MID(L2,(LEN(L2)-(LEN(LEFT(L2,LEN(L2)-SEARCH(""ENO="",L2)))-4)),((LEN(LEFT(L2,LEN(L2)-SEARCH(""ENO="",L2)))-4)-(LEN(LEFT(L2,LEN(L2)-SEARCH("",SUB"",L2))))))"
LRw = Range("L" & Rows.Count).End(xlUp).Row

Range(ActiveCell.Address, Cells(LRw, ActiveCell.Column)).FillDown

End Sub
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,130,244
Messages
5,641,058
Members
417,190
Latest member
Sdwd76

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
Top