Consulting

Results 1 to 3 of 3

Thread: How to use datavalidation in VBA

  1. #1
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location

    Question SOLVED: How to use datavalidation in VBA

    Hi i am trying to create code but dont know how to implement it to see the data validation cells.

    [vba]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[/vba]

    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 ...5.xlsm

    Thanks in advance for the help
    Last edited by lovett10; 08-19-2011 at 07:39 AM.

  2. #2
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Nvm figured it out myself it was: Range("C3").Value

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    ws.Cells(NextRow, "A").Value = .Range("C2")Text
    [/vba]

    etc.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •