VBA Hide All Columns with Text

KBartmanovich

New Member
Joined
Aug 6, 2010
Messages
6
I am trying to write a VBA Macro to hide all columns with TEXT in a certain Row.
Background:

I have a spreadsheet, in ROW4 I have Dates and Quarterly totals. The Column names are as such:
"01/01/2008", "01/02/2008", "01/03/2008", "Q1, 2008" and so on.
I am trying to set it up so that all of the columns with the TEXT format ("Q1, 2008") can be hidden.
So far I have:

Dim intColCntr, intLastCol As Integer
Dim intNoColTtl As Integer
intColCntr = 3

Cells.Select
Selection.EntireColumn.Hidden = False

If Application.WorksheetFunction.IsText(Range("A4").Offset(intColCntr + 1) & "4") Then
Range(Columns("A4").Offset(0, intColCntr + 1) & "4").Select
Selection.EntireColumn.Hidden = True
End If

Please help. I am very new to writing VBA, and cannot seem to get this one to work AT ALL!!!

Kathryn
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Welcome to the board.

Try

Rows("4:4").SpecialCells(xlCellTypeConstants, 2).EntireColumn.Hidden = True
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
If the intention is to hide columns with TEXT (non numeric and not blank) in Row 4, then that line is ALL you need.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,679
Messages
5,654,714
Members
418,149
Latest member
tjanok

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
Top