P
puakeni1
Hi all - I'm new to VBA but recently found a very useful code on the
web. I am using it to display values from specific cells in a data
validation box...neat little feature. If you click on a cell in column
B, a data validation box displays with info from other cells (that I
specified in the code), so you can see info from those cells upfront
without scrolling to the left. The only thing is that when a cell is
null (for instance cell 12 and 13), an empty line will display in it's
place in the data validation box (see code below). What code I can add
so that it ignores the null cells and doesn't display a blank lines?
I'm hoping there's something I can use. If anyone can help me, I'd
greatly appreciate it!! Thanks a bunch!
Here's the code:
____________________________________
Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Cells(2, 18) = False Then Exit Sub
With Target
If .Column = 2 And _
.Row > 2 And _
.Row < ActiveSheet.UsedRange.Row + _
ActiveSheet.UsedRange.Rows.Count Then
.EntireColumn.Validation.Delete
With .Validation
.Add Type:=xlValidateInputOnly
.InputTitle = "" ' Optional
.InputMessage = Cells(Target.Row, 10) & Chr(10) & _
Cells(Target.Row, 11) & Chr(10) & _
Cells(Target.Row, 12) & Chr(10) & _
Cells(Target.Row, 13) & Chr(10) & _
Cells(Target.Row, 14) & Chr(10) & _
Cells(Target.Row, 15) & Chr(10) & _
Cells(Target.Row, 16)
End With
End If
End With
End Sub
________________________________________
web. I am using it to display values from specific cells in a data
validation box...neat little feature. If you click on a cell in column
B, a data validation box displays with info from other cells (that I
specified in the code), so you can see info from those cells upfront
without scrolling to the left. The only thing is that when a cell is
null (for instance cell 12 and 13), an empty line will display in it's
place in the data validation box (see code below). What code I can add
so that it ignores the null cells and doesn't display a blank lines?
I'm hoping there's something I can use. If anyone can help me, I'd
greatly appreciate it!! Thanks a bunch!
Here's the code:
____________________________________
Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Cells(2, 18) = False Then Exit Sub
With Target
If .Column = 2 And _
.Row > 2 And _
.Row < ActiveSheet.UsedRange.Row + _
ActiveSheet.UsedRange.Rows.Count Then
.EntireColumn.Validation.Delete
With .Validation
.Add Type:=xlValidateInputOnly
.InputTitle = "" ' Optional
.InputMessage = Cells(Target.Row, 10) & Chr(10) & _
Cells(Target.Row, 11) & Chr(10) & _
Cells(Target.Row, 12) & Chr(10) & _
Cells(Target.Row, 13) & Chr(10) & _
Cells(Target.Row, 14) & Chr(10) & _
Cells(Target.Row, 15) & Chr(10) & _
Cells(Target.Row, 16)
End With
End If
End With
End Sub
________________________________________