Run-time 1004 for this With statement

Noid67

New Member
Joined
Feb 18, 2024
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Not sure why I am getting the Run-time 1004 error message for this With statement:

This line is the culprit:
.Range("M2:M" & .Cells(.Rows.count, "L").End(xlUp).Row).FormulaR1C1 = _
"=INT(RC[-1]/1440)&"" ""&TEXT(RC[-1]/1440-INT(RC[-1]/1440),""hh:mm:ss)"""

VBA Code:
With Sheet8 'Sheet8 = SSP_Core
        .Range("I1").value = "SDT"
        .Range("J1").value = "Trailer ID"
        .Range("K1").value = "Seal"
        .Columns("L:L").Insert shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        .Range("L1").value = "REMOVE3"
        .Range("M1").value = "Dwell Time"
        .Range("M2:M" & .Cells(.Rows.count, "L").End(xlUp).Row).FormulaR1C1 = _
                       "=INT(RC[-1]/1440)&"" ""&TEXT(RC[-1]/1440-INT(RC[-1]/1440),""hh:mm:ss)"""
    End With
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Your quotes are in the wrong place try...
VBA Code:
.Range("M2:M" & .Cells(.Rows.Count, "L").End(xlUp).Row).FormulaR1C1 = _
"=INT(RC[-1]/1440)&"" ""&TEXT(RC[-1]/1440-INT(RC[-1]/1440),""hh:mm:ss"")"
 
Upvote 0
Also, do you need to do it in pieces like that? Wouldn't this do the same thing?

VBA Code:
.Range("M2:M" & .Cells(.Rows.Count, "L").End(xlUp).Row).FormulaR1C1 = _
               "=TEXT(RC[-1]/1440,""d hh:mm:ss"")"
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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