Mikoustics
New Member
- Joined
- Jan 11, 2011
- Messages
- 6
Hi folks,
I have a macro to update cells C18 and D18 to be blank when a choice in a data validation list in B18 is changed (refreshing an INDIRECT list in cell C18 related to a B18 data validation list to blank and to a blank cell in D18). I would like this macro to be repeated for the whole cell ranges C18:C37 and D18:D37 when its adjacent choice cell (B18:B37) is changed.
e.g. If the user chooses an option from the data validation list in cell B21, I would like only cells C21 and D21 to refresh to blank.
Cheers for any help! Here is the code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngParentCell As Range
Dim rngDepCell As Range
Dim rngCell As Range
Set rngParentCell = Range("B18")
Set rngDepCell = Intersect(Target, rngParentCell)
If Not rngDepCell Is Nothing Then
Set rngCell = Range("C18:D18")
rngCell.ClearContents
rngCell.Select
MsgBox _
Title:="Notice", _
Prompt:="Please select 'Type', 'Length of Duct (m) and 'No. (Default 1)'", _
Buttons:=vbInformation + vbOKOnly
Application.SendKeys ("%{DOWN}")
End If
Set rngParentCell = Nothing
Set rngDepCell = Nothing
Set rngCell = Nothing
End Sub
I have a macro to update cells C18 and D18 to be blank when a choice in a data validation list in B18 is changed (refreshing an INDIRECT list in cell C18 related to a B18 data validation list to blank and to a blank cell in D18). I would like this macro to be repeated for the whole cell ranges C18:C37 and D18:D37 when its adjacent choice cell (B18:B37) is changed.
e.g. If the user chooses an option from the data validation list in cell B21, I would like only cells C21 and D21 to refresh to blank.
Cheers for any help! Here is the code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngParentCell As Range
Dim rngDepCell As Range
Dim rngCell As Range
Set rngParentCell = Range("B18")
Set rngDepCell = Intersect(Target, rngParentCell)
If Not rngDepCell Is Nothing Then
Set rngCell = Range("C18:D18")
rngCell.ClearContents
rngCell.Select
MsgBox _
Title:="Notice", _
Prompt:="Please select 'Type', 'Length of Duct (m) and 'No. (Default 1)'", _
Buttons:=vbInformation + vbOKOnly
Application.SendKeys ("%{DOWN}")
End If
Set rngParentCell = Nothing
Set rngDepCell = Nothing
Set rngCell = Nothing
End Sub