VBA Error

tom_blamire

Board Regular
Joined
Dec 13, 2012
Messages
99
I have a piece of VBA that I wrote which worked perfectly. For some unknown reason when it runs it is showing nothing but a blank page. Can you help?
Code:
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
    Selection.Delete
    Range("S9").Select
    Selection.ClearContents
    Columns("E:F").Select
    Selection.Delete Shift:=xlToLeft
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1:B1").Select
    Selection.ClearContents
    
    Cells.Select
    Selection.Locked = True
    Selection.FormulaHidden = True
    ActiveSheet.Protect Password:="test", DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlUnlockedCells
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Something weird has happened. I need the selection.clearcontents as it has info that has to be deleted. I changed the Columns("E:F").Select to a range and re-run the VBA and it worked?
 
Upvote 0
Try stating explicitly which range to clear, e.g.

Code:
Range("A1:B1").ClearContents
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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