By Dogstickfetch on Saturday, 20 January 2018
Posted in Excel
Replies 0
Likes 0
Views 2.8K
Votes 0
First post, I love what you all do here. Using some serious google power I've discovered VBA code to do two things I need to accomplish.

1. I have 3 data validation lists on one tab, and I want the lists to default to the TOP of the list rather than the bottom; I found this awesome code and it WORKS.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20160725
Dim xFormula As String
On Error GoTo Out:
xFormula = Target.Cells(1).Validation.Formula1
If Left(xFormula, 1) = "=" Then
Target.Cells(1) = Range(Mid(xFormula, 1)).Cells(1).Value
End If
Out:
End Sub

2. When I change the first data validation list, I want the other 2 cells to clear out and go blank, in this case B74 and B145. I found NUMEROUS websites that boast the same or very similar code, but no single variation I can find (literally pages of google links) works. This is the part that isn't working for me, and I believe it might have something to do with the code above.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "B3" Then
Range("B74,B145").ClearContents
End If
End Sub

Thank you in advance!
View Full Post