hiding column using VB

  • Thread starter Thread starter associates
  • Start date Start date
A

associates

Hi,

How do i hide columns in worksheets?

I have the following code,
Private Sub CM_Filtergroup_Click()
Beep
' clears the formulas and formatting in cells A1:G37 on "Data"
Worksheets("Data").Unprotect
Worksheets("Data").Range("A1:S200").Clear
Worksheets("Data").Column("D:E").EntireColumn.Hidden = True
ImportCSVgroup
End Sub

The above code gives me an error message saying

runtime error '438'
Object doesn't support this property or method

Need your help.

Thank you in advance
 
Hi Associates,

Tty changing:
Worksheets("Data").Column("D:E").EntireColumn.Hidden = True

to

Worksheets("Data").Column("D:E").EntireColumns.Hidden = True


(Note the final 's' in Columns)
 
Hi Associates,

Trying again(!)

Change:
Worksheets("Data").Column("D:E").EntireColumn.Hidden = True

to

Worksheets("Data").Columns("D:E").EntireColumns.Hidden = True


(Note the final 's' in Columns)
 
Hi Associates,

I thought that I had omitted the final 's', but I now see that it was
inadvertently added to the second instance of 'Column'.

The correct syntax is:

Worksheets("Data").Columns("D:E").EntireColumn.Hidden = True
 
Hi Norman,

Thank you for your reply.

Yes, it got rid of the error message there. Thanks for that

However, it doesn't hide the columns D and E.

Is there anything i missed out here?

Thank you in advance
 
Hi, Norman

Sorry, it works now. So please disregard my previous post.

Thank you for your help. :
 

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