Consulting

Results 1 to 9 of 9

Thread: Help With Vba Code! Please

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

    Question Help With Vba Code! Please

    Hi i need help writing code for my excel document.

    I have attached the document: 5.xlsm

    What i want it to be able to do:

    1. In the "Boiler" Worksheet, i want the information people enter to be stored on another sheet "CollectedInfo". and then the information to reset on the "Boiler" sheet so they can add another item if they need to.

    An explanation would be amazing as i could then change the code to work with other sheets im going to make.

    Thanks in advanced

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What are those boxes around Switches meant to be, checkboxes or textboxes?
    ____________________________________________
    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

  3. #3
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Theyre text boxes to enter quantity

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

    Sub Test()
    Dim cbo As OLEObject
    Dim ws As Worksheet
    Dim NextRow As Long

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

    ws.Range("A1:N1").Value = Array("Boiler", "Qty", "2Pos", "3Pos", "On", "Off", "2Pos", "3Pos", "On", "Off", "2Pos", "3Pos", "On", "Off")
    NextRow = 2
    Else

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

    With Worksheets("Boiler")

    ws.Cells(NextRow, "A").Value = .OLEObjects("ComboBox1").Object.Value
    ws.Cells(NextRow, "B").Value = .OLEObjects("TextBox1").Object.Value
    ws.Cells(NextRow, "C").Value = .OLEObjects("TextBox2").Object.Value
    ws.Cells(NextRow, "D").Value = .OLEObjects("TextBox3").Object.Value
    ws.Cells(NextRow, "E").Value = .OLEObjects("TextBox4").Object.Value
    ws.Cells(NextRow, "F").Value = .OLEObjects("TextBox5").Object.Value
    ws.Cells(NextRow, "G").Value = .OLEObjects("TextBox6").Object.Value
    ws.Cells(NextRow, "H").Value = .OLEObjects("TextBox7").Object.Value
    ws.Cells(NextRow, "I").Value = .OLEObjects("TextBox8").Object.Value
    ws.Cells(NextRow, "J").Value = .OLEObjects("TextBox9").Object.Value
    ws.Cells(NextRow, "K").Value = .OLEObjects("TextBox10").Object.Value
    ws.Cells(NextRow, "L").Value = .OLEObjects("TextBox11").Object.Value
    ws.Cells(NextRow, "M").Value = .OLEObjects("TextBox12").Object.Value
    ws.Cells(NextRow, "N").Value = .OLEObjects("TextBox12").Object.Value
    End With
    End Sub[/vba]
    ____________________________________________
    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

  5. #5
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    Oh my god i love you ... one thing what would i have to change in the code to allow for other sheets such as the "Conduit" one??

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The code is quite simple, examine it and work out what to pick out to add the other sheet.
    ____________________________________________
    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

  7. #7
    VBAX Regular
    Joined
    Aug 2011
    Posts
    19
    Location
    ok thanks for the help

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Typo???


    [VBA]
    ws.Cells(NextRow, "M").Value = .OLEObjects("TextBox12").Object.Value
    ws.Cells(NextRow, "N").Value = .OLEObjects("TextBox12").Object.Value
    [/VBA]

    12 or 13?

    Paul

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Yeah, you are right, it should be 13. The perils of cut and paste.
    ____________________________________________
    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
  •