Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hiding named rows


Hi!

I'm trying to write code that will hide or show rows in one worksheet
depending on if their related info is displayed in another. The rows
want to show or hide are named, so I can easily reference them. But
I'm having problems refering to the rows in code. Rows are normall
referred to by their number, but shouldn't it be possible to refer t
them by name?

This is my code:


Code
-------------------

If Target.Column = 23 Then

Dim wrkSheet As Worksheet
Set wrkSheet = ActiveWorkbook.Worksheets("Sheet3")
Dim sRowName As String
'putting together the name of the row from the value of the referencing cell
sRowName = "ROW_" & Target.Cells.Value

'rows are hidden by default, show the appropriate one!
wrkSheet.Rows(sRowName).Hidden = False

End If

-------------------


This gives me a 'Type Mismatch' error, which implies that the Row
property can't accept string indexes. Anyone got a spare clue for me
:

--
Carro
-----------------------------------------------------------------------
Carrot's Profile: http://www.excelforum.com/member.php...fo&userid=2807
View this thread: http://www.excelforum.com/showthread.php?threadid=47819

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Hiding named rows

Can't refer to them as Rows(RowName), but you can use the names like this:
ThisWorkbook.Names(sRowName).RefersToRange.Delete
- This will only work for deleting the row if the name refers to the entire
row; if not, then use
ThisWorkbook.Names(sRowName).RefersToRange.EntireR ow.Delete
--
- K Dales


"Carrot" wrote:


Hi!

I'm trying to write code that will hide or show rows in one worksheet,
depending on if their related info is displayed in another. The rows I
want to show or hide are named, so I can easily reference them. But,
I'm having problems refering to the rows in code. Rows are normally
referred to by their number, but shouldn't it be possible to refer to
them by name?

This is my code:


Code:
--------------------

If Target.Column = 23 Then

Dim wrkSheet As Worksheet
Set wrkSheet = ActiveWorkbook.Worksheets("Sheet3")
Dim sRowName As String
'putting together the name of the row from the value of the referencing cell
sRowName = "ROW_" & Target.Cells.Value

'rows are hidden by default, show the appropriate one!
wrkSheet.Rows(sRowName).Hidden = False

End If

--------------------


This gives me a 'Type Mismatch' error, which implies that the Rows
property can't accept string indexes. Anyone got a spare clue for me?
:)


--
Carrot
------------------------------------------------------------------------
Carrot's Profile: http://www.excelforum.com/member.php...o&userid=28073
View this thread: http://www.excelforum.com/showthread...hreadid=478192


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Hiding named rows

Carrot,

Try changing:
wrkSheet.Rows(sRowName).Hidden = False
to
Range(sRowName).EntireRow.Hidden = False

HTH,
Bernie
MS Excel MVP


"Carrot" wrote in message
...

Hi!

I'm trying to write code that will hide or show rows in one worksheet,
depending on if their related info is displayed in another. The rows I
want to show or hide are named, so I can easily reference them. But,
I'm having problems refering to the rows in code. Rows are normally
referred to by their number, but shouldn't it be possible to refer to
them by name?

This is my code:


Code:
--------------------

If Target.Column = 23 Then

Dim wrkSheet As Worksheet
Set wrkSheet = ActiveWorkbook.Worksheets("Sheet3")
Dim sRowName As String
'putting together the name of the row from the value of the referencing cell
sRowName = "ROW_" & Target.Cells.Value

'rows are hidden by default, show the appropriate one!
wrkSheet.Rows(sRowName).Hidden = False

End If

--------------------


This gives me a 'Type Mismatch' error, which implies that the Rows
property can't accept string indexes. Anyone got a spare clue for me?
:)


--
Carrot
------------------------------------------------------------------------
Carrot's Profile: http://www.excelforum.com/member.php...o&userid=28073
View this thread: http://www.excelforum.com/showthread...hreadid=478192



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
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
Hiding Named Ranges Matt Connor Excel Programming 12 February 17th 04 09:00 AM
Hiding Blank lines in named range Carl Brehm Excel Programming 3 August 8th 03 05:17 PM


All times are GMT +1. The time now is 03:40 PM.

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"