Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Modification in the CODE to HIDE rows and columns that start with ZERO (code given)

Hello all,

I have been trying to manipulate the code given below to hide the rows
and columns that begin with the number ZERO. But, I am landing into
some sort of error.
I know that the code given below works perfectly to hides any empty row
and column.

Can I know if there is any function or command button code that can be
written to hide the rows and columns that begin with the number ZERO?
(ZERO will be found both in column A and 1st row.) If yes, please help
me with the code.

In other words, when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden.

Thanks,
Thulasiram.

Private Sub Hide_Click()
Dim SH As Worksheet
Dim col As Range
Dim rw As Range

Set SH = ActiveSheet

For Each col In SH.UsedRange.Columns
col.Hidden = Application.CountA(col) = 0
Next col

For Each rw In SH.UsedRange.Rows
rw.Hidden = Application.CountA(rw) = 0
Next rw
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Modification in the CODE to HIDE rows and columns that start with ZERO (code given)

Dear Don Guillett,

Thanks for your response.

The code given by you works perfectly, when the user selects the range.
But, I would like to have the code the situation expalined in my
previous mail.

"when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden."

So, the user's job is to just hit the command button and not to select
the cells.

Also the code given by you hides the rows but not the columns.

Please help.

Thanks,
Thulasiram


Don Guillett wrote:
try
Sub ifzero()
For Each c In Selection
MsgBox Left(c, 1)
If Left(c, 1) = "0" Then c.EntireRow.Hidden = True
Next
End Sub


--
Don Guillett
SalesAid Software

"Thulasiram" wrote in message
oups.com...
Hello all,

I have been trying to manipulate the code given below to hide the rows
and columns that begin with the number ZERO. But, I am landing into
some sort of error.
I know that the code given below works perfectly to hides any empty row
and column.

Can I know if there is any function or command button code that can be
written to hide the rows and columns that begin with the number ZERO?
(ZERO will be found both in column A and 1st row.) If yes, please help
me with the code.

In other words, when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden.

Thanks,
Thulasiram.

Private Sub Hide_Click()
Dim SH As Worksheet
Dim col As Range
Dim rw As Range

Set SH = ActiveSheet

For Each col In SH.UsedRange.Columns
col.Hidden = Application.CountA(col) = 0
Next col

For Each rw In SH.UsedRange.Rows
rw.Hidden = Application.CountA(rw) = 0
Next rw
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Modification in the CODE to HIDE rows and columns that start with ZERO (code given)

Sub ABC()
Dim r as Range, r1 as Range, r2 as Range
Dim cell as Range
set r = Activesheet.UsedRange
set r1 = Intersect(columns(1),r.EntireRow).cells
set r2 = Intersect(rows(1),r.EntireColumn).Cells
for each cell in r1
if left(cell,1) = "0" then cell.EntireRow.Hidden = True
Next
for each cell in r2
if left(cell,1) = "0" then cell.EntireColumn.Hidden = True
Next
End Sub

--
Regards,
Tom Ogilvy


"Thulasiram" wrote in message
ups.com...
Dear Don Guillett,

Thanks for your response.

The code given by you works perfectly, when the user selects the range.
But, I would like to have the code the situation expalined in my
previous mail.

"when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden."

So, the user's job is to just hit the command button and not to select
the cells.

Also the code given by you hides the rows but not the columns.

Please help.

Thanks,
Thulasiram


Don Guillett wrote:
try
Sub ifzero()
For Each c In Selection
MsgBox Left(c, 1)
If Left(c, 1) = "0" Then c.EntireRow.Hidden = True
Next
End Sub


--
Don Guillett
SalesAid Software

"Thulasiram" wrote in message
oups.com...
Hello all,

I have been trying to manipulate the code given below to hide the rows
and columns that begin with the number ZERO. But, I am landing into
some sort of error.
I know that the code given below works perfectly to hides any empty row
and column.

Can I know if there is any function or command button code that can be
written to hide the rows and columns that begin with the number ZERO?
(ZERO will be found both in column A and 1st row.) If yes, please help
me with the code.

In other words, when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden.

Thanks,
Thulasiram.

Private Sub Hide_Click()
Dim SH As Worksheet
Dim col As Range
Dim rw As Range

Set SH = ActiveSheet

For Each col In SH.UsedRange.Columns
col.Hidden = Application.CountA(col) = 0
Next col

For Each rw In SH.UsedRange.Rows
rw.Hidden = Application.CountA(rw) = 0
Next rw
End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Modification in the CODE to HIDE rows and columns that start with ZERO (code given)

Dear Tom Ogilvy,

You are the man!

You really rock. Your codes are perfect.

Thanks a ton,
Thulasiram.

Tom Ogilvy wrote:
Sub ABC()
Dim r as Range, r1 as Range, r2 as Range
Dim cell as Range
set r = Activesheet.UsedRange
set r1 = Intersect(columns(1),r.EntireRow).cells
set r2 = Intersect(rows(1),r.EntireColumn).Cells
for each cell in r1
if left(cell,1) = "0" then cell.EntireRow.Hidden = True
Next
for each cell in r2
if left(cell,1) = "0" then cell.EntireColumn.Hidden = True
Next
End Sub

--
Regards,
Tom Ogilvy


"Thulasiram" wrote in message
ups.com...
Dear Don Guillett,

Thanks for your response.

The code given by you works perfectly, when the user selects the range.
But, I would like to have the code the situation expalined in my
previous mail.

"when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden."

So, the user's job is to just hit the command button and not to select
the cells.

Also the code given by you hides the rows but not the columns.

Please help.

Thanks,
Thulasiram


Don Guillett wrote:
try
Sub ifzero()
For Each c In Selection
MsgBox Left(c, 1)
If Left(c, 1) = "0" Then c.EntireRow.Hidden = True
Next
End Sub


--
Don Guillett
SalesAid Software

"Thulasiram" wrote in message
oups.com...
Hello all,

I have been trying to manipulate the code given below to hide the rows
and columns that begin with the number ZERO. But, I am landing into
some sort of error.
I know that the code given below works perfectly to hides any empty row
and column.

Can I know if there is any function or command button code that can be
written to hide the rows and columns that begin with the number ZERO?
(ZERO will be found both in column A and 1st row.) If yes, please help
me with the code.

In other words, when the user hits the command button, all the rows and
columns that begin with 0 (ZERO) should be hidden.

Thanks,
Thulasiram.

Private Sub Hide_Click()
Dim SH As Worksheet
Dim col As Range
Dim rw As Range

Set SH = ActiveSheet

For Each col In SH.UsedRange.Columns
col.Hidden = Application.CountA(col) = 0
Next col

For Each rw In SH.UsedRange.Rows
rw.Hidden = Application.CountA(rw) = 0
Next rw
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code to hide rows and not calculate hidden rows bradmcq Excel Discussion (Misc queries) 0 September 1st 09 12:38 AM
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
vb code to hide columns pm tlb Excel Discussion (Misc queries) 4 May 28th 09 09:36 AM
Code to Hide Rows wx4usa Excel Discussion (Misc queries) 8 December 26th 08 07:56 PM
Hide columns code jlclyde Excel Discussion (Misc queries) 0 April 25th 08 03:17 PM


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"