macca_18380
New Member
- Joined
- May 15, 2024
- Messages
- 22
- Office Version
- 365
Hi,
I'm new to this forum, forgive me if i don't understand the rules of engagement.
I'm still very much an apprentice when it comes to VBA, i did manage to find a thread on another site which addressed my need in part but the answer wouldn't work.
Essentially, I would like a macro to hide rows of data dependent upon text, which is selected via data validation, in a single cell.
Below is the code that i found and have edited to suit my needs, albeit it doesn't actually work.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iCell As Range: Set iCell = Intersect(Range("F5"), Target)
If iCell Is Nothing Then Exit Sub
If iCell.Value = "PPA Rate" Then
Rows("8:12").Hidden = False
Rows("13:17").Hidden = True
ElseIf iCell.Value = "Dev Fee" Then
Rows("8:12").Hidden = True
Rows("13:17").Hidden = False
'Else ' do nothing
End If
End Sub
The macro doesn't work when i paste this into a module, why is this the case?
Thank you
Michael
I'm new to this forum, forgive me if i don't understand the rules of engagement.
I'm still very much an apprentice when it comes to VBA, i did manage to find a thread on another site which addressed my need in part but the answer wouldn't work.
Essentially, I would like a macro to hide rows of data dependent upon text, which is selected via data validation, in a single cell.
Below is the code that i found and have edited to suit my needs, albeit it doesn't actually work.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iCell As Range: Set iCell = Intersect(Range("F5"), Target)
If iCell Is Nothing Then Exit Sub
If iCell.Value = "PPA Rate" Then
Rows("8:12").Hidden = False
Rows("13:17").Hidden = True
ElseIf iCell.Value = "Dev Fee" Then
Rows("8:12").Hidden = True
Rows("13:17").Hidden = False
'Else ' do nothing
End If
End Sub
The macro doesn't work when i paste this into a module, why is this the case?
Thank you
Michael