Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to hide rows/colums by value

HIDING
I'd like to be able to hide various rows and columns that have the
number 1 in their first position.

For example:

If A4 =1 then hide row 4.

If B6=1 then hide column B.

I'm okay with never being alble to hide row 1 or column A so there
shouldn't be any conflict/ambiguity.

UNHIDING
I'm happy to just unhide all when I need to unhide any. How can I do
that?

Would someone point me in the right direction?

Thanks for any help.

/e
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro to hide rows/colums by value

why a row for A4 and a column for B6?

What are your rules,

What cells should be checked.

Is this something you would do by running a macro, or do you want them to
magically hide when you enter the 1 - or is the 1 produced by calculation.

Help yourself by providing a complete explanation of what you want to do.

sub RunMe()
With Range("A4")
.EntireRow.Hidden = ( .Value = 1)
end with
With Range("B6")
.entirecolumn.Hidden = (.Value = 1)
End With
End sub

--
Regards,
Tom Ogilvy






" wrote:

HIDING
I'd like to be able to hide various rows and columns that have the
number 1 in their first position.

For example:

If A4 =1 then hide row 4.

If B6=1 then hide column B.

I'm okay with never being alble to hide row 1 or column A so there
shouldn't be any conflict/ambiguity.

UNHIDING
I'm happy to just unhide all when I need to unhide any. How can I do
that?

Would someone point me in the right direction?

Thanks for any help.

/e

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to hide rows/colums by value

Tom,

A4 and B6 were examples.

I'd like to be able to define the rows rows and columns to hide by
manually placing a value of 1 in cells around the perimeter of the
sheet.

I do not need execution of the hide and unhide macros hooked to any
events; I'll run them manually.

That is:

Columns: For each column I want to hide, I'll place a 1 in row 1 at
the corresponding column.

Rows: For each row I want to hide, I'll place a 1 in column A on the
corresponding row.

But the question arises: Should we hide a row or a column if user
placed 1 in A1? So I originally said I'd be happy to ignore A1. But I
now see that a 1 in A1 should hide both row 1 AND column A. That'd be
perfect as I don't need to see those manually placed 1 values except
after an "unhide all" operation..

Is that fully clear?

Thanks.

/e





On Tue, 12 Sep 2006 09:37:03 -0700, Tom Ogilvy
wrote:

why a row for A4 and a column for B6?

What are your rules,

What cells should be checked.

Is this something you would do by running a macro, or do you want them to
magically hide when you enter the 1 - or is the 1 produced by calculation.

Help yourself by providing a complete explanation of what you want to do.

sub RunMe()
With Range("A4")
.EntireRow.Hidden = ( .Value = 1)
end with
With Range("B6")
.entirecolumn.Hidden = (.Value = 1)
End With
End sub

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to hide rows/colums by value

Eliano,

Thanks, but is there a way to adapt your solution to every row and
column (or perhaps a range of 20 rows and columns) instead of A1
explicitly -- so I don't have to write multiple versions of that macro
for every column or row?

/e


On 12 Sep 2006 13:58:48 -0700, "eliano"
wrote:

Sorry.:-)

Manually ?
.EntireRow.Hidden = (.Value = "R")
.EntireColumn.Hidden = (.Value = "C")

Eliano

eliano ha scritto:

Hi friends.
Try:

Sub RunMe()
With Range("A1")
.EntireRow.Hidden = (.Value = "a")
'End With
'With Range("A1")
.EntireColumn.Hidden = (.Value = "A")
End With
End Sub

Regards,
Eliano


ha scritto:

Tom,

A4 and B6 were examples.

I'd like to be able to define the rows rows and columns to hide by
manually placing a value of 1 in cells around the perimeter of the
sheet.

I do not need execution of the hide and unhide macros hooked to any
events; I'll run them manually.

That is:

Columns: For each column I want to hide, I'll place a 1 in row 1 at
the corresponding column.

Rows: For each row I want to hide, I'll place a 1 in column A on the
corresponding row.

But the question arises: Should we hide a row or a column if user
placed 1 in A1? So I originally said I'd be happy to ignore A1. But I
now see that a 1 in A1 should hide both row 1 AND column A. That'd be
perfect as I don't need to see those manually placed 1 values except
after an "unhide all" operation..

Is that fully clear?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to hide rows/colums by value

Dim Cols as Range, Rws as Range
Dim cell as Range
Rows.Hidden = False
Columns.Hidden = False
On Error Resume Next
set Cols = rows(1).SpecialCells(xlConstants,xlNumbers)
set Rws = columns(1).SpecialCells(xlConstants,xlNumbers)
On Error goto 0
if not Cols is nothing then
for each cell in cols
if cell.Value = 1 then
cell.EntireColumn.Hidden = True
end if
Next
End if
if not Rws is nothing then
for each cell in Rws
if cell.Value = 1 then
cell.EntireRow.Hidden = True
end if
next
End if

--
regards,
Tom Ogilvy



wrote in message
...
Tom,

A4 and B6 were examples.

I'd like to be able to define the rows rows and columns to hide by
manually placing a value of 1 in cells around the perimeter of the
sheet.

I do not need execution of the hide and unhide macros hooked to any
events; I'll run them manually.

That is:

Columns: For each column I want to hide, I'll place a 1 in row 1 at
the corresponding column.

Rows: For each row I want to hide, I'll place a 1 in column A on the
corresponding row.

But the question arises: Should we hide a row or a column if user
placed 1 in A1? So I originally said I'd be happy to ignore A1. But I
now see that a 1 in A1 should hide both row 1 AND column A. That'd be
perfect as I don't need to see those manually placed 1 values except
after an "unhide all" operation..

Is that fully clear?

Thanks.

/e





On Tue, 12 Sep 2006 09:37:03 -0700, Tom Ogilvy
wrote:

why a row for A4 and a column for B6?

What are your rules,

What cells should be checked.

Is this something you would do by running a macro, or do you want them to
magically hide when you enter the 1 - or is the 1 produced by calculation.

Help yourself by providing a complete explanation of what you want to do.

sub RunMe()
With Range("A4")
.EntireRow.Hidden = ( .Value = 1)
end with
With Range("B6")
.entirecolumn.Hidden = (.Value = 1)
End With
End sub



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to hide rows/colums by value

Thank you very much. That works exactly as I described.

/e


On Tue, 12 Sep 2006 22:37:22 -0400, "Tom Ogilvy"
wrote:

Dim Cols as Range, Rws as Range
Dim cell as Range
Rows.Hidden = False
Columns.Hidden = False
On Error Resume Next
set Cols = rows(1).SpecialCells(xlConstants,xlNumbers)
set Rws = columns(1).SpecialCells(xlConstants,xlNumbers)
On Error goto 0
if not Cols is nothing then
for each cell in cols
if cell.Value = 1 then
cell.EntireColumn.Hidden = True
end if
Next
End if
if not Rws is nothing then
for each cell in Rws
if cell.Value = 1 then
cell.EntireRow.Hidden = True
end if
next
End if

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
Hide data in specific rows/colums/cells in Excel 2003 Ben Excel Discussion (Misc queries) 3 October 21st 07 04:33 PM
Chart disappears if you hide rows/colums with data. Philip Gump Excel Discussion (Misc queries) 1 April 3rd 06 04:36 AM
Macro to Hide Colums keen learner Excel Programming 2 March 8th 06 12:10 PM
macro total for colums with changing # of rows BillyRogers Excel Programming 5 January 26th 06 08:58 PM
What is the quickest way to hide a lot of rows and colums ? Stephen Tyrrell Excel Discussion (Misc queries) 2 August 19th 05 08:20 AM


All times are GMT +1. The time now is 12:05 AM.

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

About Us

"It's about Microsoft Excel"