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