Autofill Not Working When Run From Another Sheet

Hmerman

Board Regular
Joined
Oct 2, 2016
Messages
102
Hello

I am trying to run a macro that Autofills a formula in Sheet18 from Sheet 10, but I keep getting an error "Autofill Mehod of Range class failed".
<code>
'Demarcate autofill in accordance with last row of values in Column C</code><code>
lastRow1 = Sheet18.Range("C" & Rows.Count).End(xlUp).row
</code><code>
</code><code>

With Sheet18
'Insert function to check for S and A at beginning of Column F values

Application.EnableEvents = False</code><code>
.Range("U2").Formula = "=IF(LEFT(H2,1) = ""S"",0.8,IF(LEFT(H2,1)=""A"",0.5,""PROBLEEM""))"
</code>
<code></code><code>
.Range("U2").AutoFill Destination:=Range("U2:U" & lastRow1), Type:=xlFillDefault
Application.EnableEvents = True

End With
</code>
I get the error on the red line, can someone please help me to rectify the code?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
try
Application.EnableEvents = False

<code style="background-color: transparent; color: rgb(51, 51, 51); font-family: monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 13.33px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">
.Range("U2:U" & lastRow1).Formula = "=IF(LEFT(H2,1) = ""S"",0.8,IF(LEFT(H2,1)=""A"",0.5,""PROBLEEM""))"​
</code><code style="background-color: transparent; color: rgb(51, 51, 51); font-family: monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 13.33px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">

Application.EnableEvents = True
</code>
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

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