Selecting columns

R

Richard Edwards

Good Morning all - (well it was a good morning until i got out of bed!)

I have been using a workbook for months without any problems and this
morning....not working.

The only piece of code that i have changed is changing the background of a
commandbutton when it is pressed.

The code is:

Private Sub CommandButton3_Click()
CommandButton3.BackColor = vbRed
CommandButton1.BackColor = vbRed
Call clear_old_locates
End Sub

Private Sub clear_old_locates()
Sheets("MS").Select
Columns("E:I").Select
Selection.ClearContents
End Sub

When it reaches the "Columns("E:I").Select" i get an error.

"Run-time error '1004';
Application-defined or object-defined error"

I have tried changing the way i select the column using ranges, etc but
still get thrown out errors...

Any ideas?!

Thx


Richard
 
B

Bob Phillips

Me too, but this works


Private Sub clear_old_locates()
Sheets("MS").Columns("E:I").ClearContents
End Sub
 
R

Richard Edwards

fantastic. thanks very much.

how odd - as i say it had been working for months...

have a good day.

rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top