PDA

View Full Version : How to use datavalidation in VBA



lovett10
08-19-2011, 07:06 AM
Hi i am trying to create code but dont know how to implement it to see the data validation cells.

Private Sub CommandButton1_Click()
Dim cbo As OLEObject
Dim ws As Worksheet
Dim NextRow As Long

Set ws = Worksheets("ConduitCollectedInfo")
If ws.Range("A1").Value2 = "" Then

ws.Range("A1:N1").Value = Array("Colour", "Size", "Product", "Quantity")
NextRow = 2
Else

NextRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row + 1
End If

With Worksheets("Conduit")

ws.Cells(NextRow, "A").Value =
ws.Cells(NextRow, "B").Value =
ws.Cells(NextRow, "C").Value =
ws.Cells(NextRow, "D").Value = .OLEObjects("Textbox1").Object.Value
End With
End Sub

Thats my code i need the Rows A,B and C to match up with the 3 data validation lists i have.

Ive uploaded incase i make no sense :P ...6444

Thanks in advance for the help

lovett10
08-19-2011, 07:38 AM
Nvm figured it out myself it was: Range("C3").Value

Bob Phillips
08-19-2011, 07:39 AM
ws.Cells(NextRow, "A").Value = .Range("C2")Text


etc.