Run-Time error "1004 Unable to set the NumberFormat property of the Range Class

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings,

I have a macro which is resulting in me get the error described in the Subject Line.
The current Format in Column E is Custom: dd mmm yyyy hhmm.

My macro is:
Sub twenty_four_hour_Clock()
VBA Code:
   With Range("E1", Range("E" & Rows.Count).End(xlUp))
      .NumberFormat = "E"
      .Value = Evaluate(Replace("if(@="""","""",if(isnumber(@),text(mod(@,1),""hhmm""),@))", "@", .Address))
   End With

Thank you very much
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Have you tried:
.NumberFormat = "dd mmm yyyy hhmm"
 
Upvote 0
@Livin404 is this in regards to your fill in missing dates question that I recommended that you start a new thread about? I ask because you had the same mistake in that code.
 
Upvote 0
"E" It is not a valid format

As JoeMo comments
Try :

.NumberFormat = "dd mmm yyyy hhmm"
Thank you for getting back. I don't know how I ended up with an "E". I suddenly realized I meant to have
Excel Formula:
.NumberFormat = "@"
. This allows me to remove everything but the last four digit of Julian Date and Time. The date is identified by another Macro I used which inserts the date.
 
Upvote 0

Forum statistics

Threads
1,215,873
Messages
6,127,470
Members
449,384
Latest member
purevega

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