PDA

View Full Version : Solved: New to VBA, a simple question



danli759
06-17-2011, 05:49 AM
Hi!

(I use excel 2007)

I write this to clear cell A1:

Sub ClearRange()
Range(“A1”).ClearContents
End Sub


And get this error message:
Run-time error '1004'
Method 'Range' of object '_Global' failed


I get this every time I try using Range, I do have the sheet active that i want to operate on.

What can I do?


Thanks
/Dan

Kenneth Hobs
06-17-2011, 05:57 AM
Welcome to the forum! Be sure to use straight quote marks. Is your worksheet protected and if so, is the cell locked?

danli759
06-17-2011, 05:59 AM
Welcome to the forum! Be sure to use straight quote marks. Is your worksheet protected and if so, is the cell locked?


The straight quote marks did it!

Thank you!