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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the board.

Try

Rows("4:4").SpecialCells(xlCellTypeConstants, 2).EntireColumn.Hidden = True
 
Upvote 0
If the intention is to hide columns with TEXT (non numeric and not blank) in Row 4, then that line is ALL you need.
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,040
Members
448,543
Latest member
MartinLarkin

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
Back
Top