Hey all!
Having trouble with my VBA code which is used to clear the contents of a specific range of cells. It works well up to a specific range, but when I add another one it gives me "Runt-time error '1004': Method 'Range' of object '_Global' failed".
This is my code when it is working:
Sub continue()
CarryOn = MsgBox("Vill du radera all tid?", vbYesNo, "Tidrapportering")
If CarryOn = vbYes Then
'declare object variable to hold reference to cells to clear contents but not formatting
Dim myRange As Range
'identify cells to clear contents and keep formatting
Set myRange = Range("E1:W4,E7:W10,E13:W16,E19:W22,E25:W28,E31:W34,E37:W40,E43:W46,E49:W52,E55:W58,E61:W64,E67:W70,E73:W76,E79:W82,E85:W88,E91:W94,E97:W100,E103:W106,E109:W112,E115:W118,E121:W124,E127:W130,E133:W136,E139:W142,E145:W148,E151:W154,E157:W160,E163:W166,E169:W172")
'clear cell contents (but not formatting)
myRange.ClearContents
End If
End Sub
As soon as I add the range E175:W178 it gives me the error
Bookmarks