Results 1 to 3 of 3

Thread: [RESOLVED] Form data excel sheet - yeah i know whats new!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [RESOLVED] Form data excel sheet - yeah i know whats new!

    Hi all,

    I've got a excel workbook that i need to be able to automate standard info into via a form, most of the code ive seen online so far is nice a easy, but they all have a similar theme, for the data to import at the bottom of the sheet, where as i would prefer the information to populate at the top.

    should be easy enough... but i'm hitting a brick wall. heres what i have so far.

    the only code that works is the insert row and user form initialise, the rest doesnt work at all.

    Code:
    Private Sub UserForm_Initialize()
    Dim Cbranch As Range
    Dim cbar As Range
    Dim br As Worksheet
    Set br = Worksheets("Branch list")
    
    For Each Cbranch In br.Range("BARList")
        With Me.cmbBranch
            .AddItem Cbranch
            .List(.ListCount - 1, 1) = Cbranch.Offset(0, 1).Value
          End With
    Next Cbranch
        
    For Each cbar In br.Range("BRstatus")
        With Me.CmbStatus
            .AddItem cbar.Value
        End With
    Next cbar
    End Sub
    Private Sub cmdOk_Click()
    Dim Cname As Long
    Dim Cstatus As Long
    Dim Cday As Long
    Dim Cbranch As Long
    Dim Cchange As Long
    
        Rows("3:3").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("A2").Select
        Range("A3").Select
    
    Cname = txtname.Value.Cells("A3", 0)
    Cstatus = CmbStatus.Value.Cells("B3", 0)
    Cday = txtday.Value.Cells("C3", 0)
    Cbranch = cmbBranch.Value.Cells("E3", 0)
    Cchange = txtchange.Value.Cells("F3", 0)
    
    Unload Me
    
    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Form data excel sheet - yeah i know whats new!

    try like
    vb Code:
    1. Set cel = Range("a3")
    2. cel.EntireRow.Insert
    3. cel.Offset(-1) = txtname
    4. cel.Offset(-1, 1) = cmbstatus.Text
    5. cel.Offset(-1, 2) = txtday
    6. 'etc
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Re: Form data excel sheet - yeah i know whats new!

    Awesome works like a charm! thanks again!

Posting Permissions

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



Click Here to Expand Forum to Full Width