Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Another Hide Columns Question

I am running Excel 2003 and need help with a macro. I have a table consisting
of Region, Stores and Monthly Sales. I wrote a macro to filter (hide) Stores
depending on the Region.

Region Store Sales City
Region1 Store1 $170K City1
Region1 Store2 $160K City2
Region2 Store1 $220K City1
Region2 Store3 $250K City1
Region3 Store1 $200K City2

In the following macro, the target value of A1 (Region) is located on
another worksheet, but I want to use that information to hide the Store
(column) that are not in the Region. When I run the macro, there is no change
in the results.

Any help would be greatly appreciated

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
Range("A:D").EntireColumn.Hidden = False
If Target.Value = "Region1" Then
Range("A:B").EntireColumn.Hidden = True
Range("C:D").EntireColumn.Hidden = False
Else
Range("A:B").EntireColumn.Hidden = False
Range("C:D").EntireColumn.Hidden = True
End If
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Another Hide Columns Question

Copy the code below, right click the tab of the "another worksheet" where A1 is located, select
"View Code" and paste the code into the window that appears.

My code assumes that the sheet with the data table is named "Data", and that the table starts in
cell A1.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
Worksheets("Data").Range("A1").CurrentRegion.AutoF ilter Field:=1, Criteria1:=Target.Value
End If
End Sub


"Dallas PM" wrote in message
...
I am running Excel 2003 and need help with a macro. I have a table consisting
of Region, Stores and Monthly Sales. I wrote a macro to filter (hide) Stores
depending on the Region.

Region Store Sales City
Region1 Store1 $170K City1
Region1 Store2 $160K City2
Region2 Store1 $220K City1
Region2 Store3 $250K City1
Region3 Store1 $200K City2

In the following macro, the target value of A1 (Region) is located on
another worksheet, but I want to use that information to hide the Store
(column) that are not in the Region. When I run the macro, there is no change
in the results.

Any help would be greatly appreciated

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
Range("A:D").EntireColumn.Hidden = False
If Target.Value = "Region1" Then
Range("A:B").EntireColumn.Hidden = True
Range("C:D").EntireColumn.Hidden = False
Else
Range("A:B").EntireColumn.Hidden = False
Range("C:D").EntireColumn.Hidden = True
End If
End If
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Another Hide Columns Question

TY for the response. I am looking to view the profitability of each store
collectively and by region with the end result looking similar to:

Region1 (A1)

City1 City2
Store1 $170K
Store2 $160K


Region2 (A1)

City1
Store1 $220K
Store3 $250K


Region3 (A1)


City2
Store1
$200K


Region0 (A1)

City1 City2 City1 City2
Store1 $170K
Store2 $160K
Store1 $220K
Store3 $250K
Store1 $200K


"Bernie Deitrick" wrote:

Copy the code below, right click the tab of the "another worksheet" where A1 is located, select
"View Code" and paste the code into the window that appears.

My code assumes that the sheet with the data table is named "Data", and that the table starts in
cell A1.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
Worksheets("Data").Range("A1").CurrentRegion.AutoF ilter Field:=1, Criteria1:=Target.Value
End If
End Sub


"Dallas PM" wrote in message
...
I am running Excel 2003 and need help with a macro. I have a table consisting
of Region, Stores and Monthly Sales. I wrote a macro to filter (hide) Stores
depending on the Region.

Region Store Sales City
Region1 Store1 $170K City1
Region1 Store2 $160K City2
Region2 Store1 $220K City1
Region2 Store3 $250K City1
Region3 Store1 $200K City2

In the following macro, the target value of A1 (Region) is located on
another worksheet, but I want to use that information to hide the Store
(column) that are not in the Region. When I run the macro, there is no change
in the results.

Any help would be greatly appreciated

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
Range("A:D").EntireColumn.Hidden = False
If Target.Value = "Region1" Then
Range("A:B").EntireColumn.Hidden = True
Range("C:D").EntireColumn.Hidden = False
Else
Range("A:B").EntireColumn.Hidden = False
Range("C:D").EntireColumn.Hidden = True
End If
End If
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
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
Hide Columns hajo Excel Worksheet Functions 4 September 2nd 06 08:09 PM
Hide Rows / Columns - complex question lw new guest Excel Worksheet Functions 2 August 18th 05 08:02 PM
Hide columns alm09 Excel Discussion (Misc queries) 1 June 27th 05 04:14 PM
hide columns varun Excel Worksheet Functions 1 December 2nd 04 10:05 AM


All times are GMT +1. The time now is 10:09 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"