ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide Column - With text in cell (https://www.excelbanter.com/excel-programming/345119-hide-column-text-cell.html)

O&O

Hide Column - With text in cell
 
How can I make this macro work if my cells contain a text e.g AAA
instead of 0 & work on Sheet1, Sheet2 & Sheet3

Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < 0 Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub

Thxs


Bob Phillips[_6_]

Hide Column - With text in cell
 
Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
How can I make this macro work if my cells contain a text e.g AAA
instead of 0 & work on Sheet1, Sheet2 & Sheet3

Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < 0 Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub

Thxs




O&O

Hide Column - With text in cell
 
Thxs - but how about Sheet1 &Sheet2 &Sheet3
thxs
Bob Phillips wrote:
Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
How can I make this macro work if my cells contain a text e.g AAA
instead of 0 & work on Sheet1, Sheet2 & Sheet3

Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < 0 Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub

Thxs



Bob Phillips[_6_]

Hide Column - With text in cell
 


--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
Thxs - but how about Sheet1 &Sheet2 &Sheet3
thxs
Bob Phillips wrote:
Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
How can I make this macro work if my cells contain a text e.g AAA
instead of 0 & work on Sheet1, Sheet2 & Sheet3

Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < 0 Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub

Thxs





Bob Phillips[_6_]

Hide Column - With text in cell
 
Sorry, didn't realise you want that included in the code

Sub Test1()
Dim cell As Range
Dim arySheets
Dim sh As Worksheet

arySheets = Array("Sheet1", "Sheet2", "Sheet3")
For Each sh In Worksheets(arySheets)
For Each cell In sh.Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
Next sh
End Sub




--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
Thxs - but how about Sheet1 &Sheet2 &Sheet3
thxs
Bob Phillips wrote:
Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
How can I make this macro work if my cells contain a text e.g AAA
instead of 0 & work on Sheet1, Sheet2 & Sheet3

Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < 0 Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub

Thxs





al007

Hide Column - With text in cell
 
thxs!!!
Bob Phillips wrote:
Sorry, didn't realise you want that included in the code

Sub Test1()
Dim cell As Range
Dim arySheets
Dim sh As Worksheet

arySheets = Array("Sheet1", "Sheet2", "Sheet3")
For Each sh In Worksheets(arySheets)
For Each cell In sh.Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
Next sh
End Sub




--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
Thxs - but how about Sheet1 &Sheet2 &Sheet3
thxs
Bob Phillips wrote:
Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < "AAA" Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"O&O" wrote in message
oups.com...
How can I make this macro work if my cells contain a text e.g AAA
instead of 0 & work on Sheet1, Sheet2 & Sheet3

Sub Test1()
Dim cell As Range
For Each cell In Range("c1:j1")
If cell.Value < 0 Then
cell.EntireColumn.Hidden = True
End If
Next cell
End Sub

Thxs





All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com