Runtime error 1004 again.

EBoudreau

Board Regular
Joined
Aug 21, 2015
Messages
153
I'm getting the following run time error on the following code in bold:

Rich (BB code):
Sub Capitalise(rngToConvert As Range)


    Dim rng As Range
    
    For Each rng In rngToConvert
        With rng
            If Not .HasFormula Then .Value = UCase(.Value)
        End With
    Next rng


End Sub
Sub ConvertToTime(rngToConvert As Range)


    Dim rng As Range
    
    For Each rng In rngToConvert
        rng.Value = Format(rng.Value, "00\:00")
    Next rng
    
    rngToConvert.NumberFormat = "HH:MM"


End Sub

I have the cells formatted as "13:50" and have tried it as "hh:mm".

Any ideas?
 
Yes it is. Always has been but now for some reason when i got down to a certain cell number, it started giving me an error. The cells are all within the range specified in the code though.
 
Upvote 0
But when I unprotect the sheet it works fine. How can that be resolved so it works when protected.
 
Upvote 0
Did you allow formatting cells when you protected the sheet?
 
Upvote 0
Solution
I looked into it and found that there was code that was missing that was auto protecting the form which I removed to make a lot of edits but apparently had to re-insert to make the form work properly.
Thank you all for chiming in! This community is a great help!
 
Upvote 0

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