VBAEXCELNew
New Member
- Joined
- Apr 3, 2023
- Messages
- 38
- Office Version
- 365
- 2021
- Platform
- Windows
Hello,
i have a script where i want my Cell C14 to be a placeholder script, where if cell b14 were to be selected as "Others" in a drop down list
Example:
Currently i have found that there is a place holder where it nicely if were put in C 14 However due to a condition in B14 i dont wan my placeholder to be show
in every cell i selected in B14
my script currently i am using is this
Currently i have found this VBA script for Placeholder
Now how can i combine my placeholder script to the above i am using for ?
i have a script where i want my Cell C14 to be a placeholder script, where if cell b14 were to be selected as "Others" in a drop down list
Example:
Currently i have found that there is a place holder where it nicely if were put in C 14 However due to a condition in B14 i dont wan my placeholder to be show
in every cell i selected in B14
my script currently i am using is this
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Target is passed as an argument when the event fires. It is the Range that changed and caused the event to fire.
' You can use it to run your code only when certain cells change.
If Target.CountLarge > 1 Then Exit Sub
'Returns a value that represents the number of objects in the collection.
'The CountLarge property is functionally the same as the Count property, except that the Count property will
'generate an overflow error if the specified range has more than 2,147,483,647 cells (one less than 2,048 columns).
If Target.Address <> "$B$14" Then Exit Sub
'Target the address not = cell b14
If Target = "Others" Then
With Target.Offset(0, 1)
.Value = "Please Specify"
'.Font.Italic = True
.Font.Color = Black
'.Font.ColorIndex = 16
.Borders.LineStyle = xlContinuous
End With
Else
With Target.Offset(0, 1)
.ClearContents
'.Font.Italic = False
.Borders.LineStyle = xlNone
End With
End If
End Sub
Currently i have found this VBA script for Placeholder
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const PlaceHolder As String = "Please Specify" 'Change what you want the place holder to be
Dim DesiredPlaceHolderCells As Range, C As Range
Set DesiredPlaceHolderCells = Range("$C$14") 'Change cell(s) that you want to act as place holders within the "" marks, seperated by commas
If Target.CountLarge > 1 Then GoTo Skip
If Not Intersect(DesiredPlaceHolderCells, Target) Is Nothing And Target.Value = PlaceHolder Then
Target.Font.Color = vbBlack
Target = ""
End If
Skip:
For Each C In DesiredPlaceHolderCells
If C = "" And C.Address <> Target.Address Then
C.Font.ColorIndex = 16 'grey
C = PlaceHolder
End If
Next C
End Sub
Now how can i combine my placeholder script to the above i am using for ?