error in my code need help plzzzz

  • Thread starter Thread starter 4ndy
  • Start date Start date
4

4ndy

hi again

im having a bit of a problem, when i try to execute this code i get a
error with the fourth line highlighted in yellow,
Private Sub CommandButton1_Click()
UserForm1.Hide
Sheets("workings").Select
Range("B18").Select
Selection.ClearContents
Range("B20").Select
Selection.ClearContents
Range("B22").Select
Selection.ClearContents
Range("B24").Select
Selection.ClearContents
Range("B26").Select
Selection.ClearContents
Range("B30").Select
Selection.ClearContents
Range("H18").Select
Selection.ClearContents
Range("H19").Select
Selection.ClearContents
Range("H20").Select
Selection.ClearContents
Range("H21").Select
Selection.ClearContents
Range("H22").Select
Selection.ClearContents
Range("J18").Select
Selection.ClearContents
Range("J20").Select
Selection.ClearContents
Range("J22").Select
Selection.ClearContents
Sheets("show").Select
no2.Show
End Sub

Can anyone else see where i'm goin wrong in this code, its to clear al
of the current selections and reset them to norma
 
4ndy,

I don't see anything wrong with the code. I'm not sure whether to count
Private Sub CommandButton1 as the first line or not. Tell use specifically
the line, and what the error is. Is there a sheet named "workings"?


You might want to trim this to

Range("B18").ClearContents
Range("B20").ClearContents
' etc.

You could also create a single Range Name for these cells, then use

Range("MyRange").ClearContents
 
or even

Range("B18,B20").ClearContents

--

HTH

RP

Earl Kiosterud said:
4ndy,

I don't see anything wrong with the code. I'm not sure whether to count
Private Sub CommandButton1 as the first line or not. Tell use specifically
the line, and what the error is. Is there a sheet named "workings"?


You might want to trim this to

Range("B18").ClearContents
Range("B20").ClearContents
' etc.

You could also create a single Range Name for these cells, then use

Range("MyRange").ClearContents
 

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

Back
Top