Runtime Error 1004 with Macro

VinceF

Board Regular
Joined
Sep 22, 2007
Messages
192
Office Version
  1. 2016
Platform
  1. Windows
Help please...

Trying to make a Macro to do this,
in cell L5 I put in the formula =IF(K5="","",RAND()) and drag it down to cell L44
When I execute the Macro I get a Runtime Error 1004

Sub UNLOCKGROUPS()
'
' UNLOCKGROUPS Macro
'

'
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",RAND())"
Range("L5").Select
Selection.AutoFill Destination:=Range("L5:L44"), Type:=xlFillDefault
Range("L5:L44").Select
Range("L3").Select
End Sub

Much Appreciated
VinceF
excel 2016
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You do not need autofill, you can assign the formula to the whole range at once, like this:
VBA Code:
Sub UNLOCKGROUPS()
'
' UNLOCKGROUPS Macro

    Range("L5:L44").FormulaR1C1 = "=IF(RC[-1]="""","""",RAND())"

End Sub
One line of code - that is all you need!
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,579
Members
452,653
Latest member
craigje92

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