Help with an error (1004)

Tobbes

New Member
Joined
Feb 26, 2009
Messages
47
I cant seem to work out why this errors:
Code:
Sub ReturnToStart()
ret = MsgBox("Are you sure you want to reset all the completions and start a new HSC servicing?", vbYesNo + vbCritical, "Confirm Reset")
If ret = vbYes Then
    For a = 1 To 5
    For c = 1 To 65536
        If Sheets("HSC 3 Day " & a).Cells(c, 6).Value = "P" Then
            Sheets("HSC 3 Day " & a).Cells(c, 6).Value = ""
        Else
        End If
    Next
    Next
    Sheets("CFUs").Range("B4", Range("B4").End(xlDown).Offset(0, 3)).ClearContents
    Call Completer
Else
End If
End Sub
It errors on this code "Sheets("CFUs").Range("B4", Range("B4").End(xlDown).Offset(0, 3)).ClearContents"
However if I use Range("B4:E46"), instead of the dyanmic down-and-across, it works....:confused:
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Code:
Sheets("CFUs").Range("B4", Sheets("CFUs").Range("B4").End(xlDown).Offset(0, 3)).ClearContents
 
Upvote 0
I think glenn has answered your question but you might like to consider an alternative method for another part of your code

I think

Code:
    For c = 1 To 65536
        If Sheets("HSC 3 Day " & a).Cells(c, 6).Value = "P" Then
            Sheets("HSC 3 Day " & a).Cells(c, 6).Value = ""
        Else
        End If
    Next
can be replaced with:
Code:
    Sheets("HSC 3 Day " & a).Columns(6).Replace what:="P", replacement:="", lookat:=xlWhole
 
Upvote 0
Thank you both. MrExcel continues to teach me something new everyday.
You guys are the difference between Intelligence and genius.
 
Upvote 0

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,920
Latest member
jaspers

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