It was a little hard for me to follow what you were attempting to do
I'm guessing that after the pipe size was selected, the validation list for the other 2 were to be restricted to only the values for that pipe size
Not a lot of error checking, and I changed the destination columns to B (easier for me to see what's going on)
Standard module:
Option Explicit
Sub ValidString(ValidCol As Long, ValidDest As Range)
Dim r As Range
Dim i As Long
Dim s As Variant
Set r = Worksheets("Temp").Cells(1, 1).CurrentRegion
s = "," ' needed
For i = 3 To r.Rows.Count - 1
If r.Cells(i, ValidCol).Value <> r.Cells(i + 1, ValidCol).Value Then
s = s & r.Cells(i, ValidCol).Text & ","
End If
Next i
s = Left(s, Len(s) - 1)
With ValidDest
.NumberFormat = "@"
.HorizontalAlignment = xlHAlignRight
With .Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=s
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End With
End Sub
Sub ValidString2(ValidCol As Long, ValidDest As Range, PrimFilter As String)
Dim r As Range
Dim i As Long
Dim s As Variant
Set r = Worksheets("Temp").Cells(1, 1).CurrentRegion
s = "," ' needed
For i = 3 To r.Rows.Count - 1
If r.Cells(i, ValidCol).Value <> r.Cells(i + 1, ValidCol).Value Then
If r.Cells(i, 1).Value = PrimFilter Then
s = s & r.Cells(i, ValidCol).Text & ","
End If
End If
Next i
s = Left(s, Len(s) - 1)
With ValidDest
.NumberFormat = "@"
.HorizontalAlignment = xlHAlignRight
With .Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=s
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End With
End Sub
ThisWorkbook:
Option Explicit
Private Sub Workbook_Open()
Application.EnableEvents = False
Call ValidString(1, Worksheets("Calc").Range("B2"))
Worksheets("Calc").Range("B2").ClearContents
Worksheets("Calc").Range("B3").ClearContents
Worksheets("Calc").Range("B4").ClearContents
Application.EnableEvents = True
End Sub
Worksheet Calc:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$B$2" Then Exit Sub
Application.EnableEvents = False
Call ValidString2(6, Worksheets("Calc").Range("B3"), Worksheets("Calc").Range("B2"))
Call ValidString2(8, Worksheets("Calc").Range("B4"), Worksheets("Calc").Range("B2"))
Application.EnableEvents = True
End Sub