[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
Re: Form data excel sheet - yeah i know whats new!
try like
vb Code:
Set cel = Range("a3")
cel.EntireRow.Insert
cel.Offset(-1) = txtname
cel.Offset(-1, 1) = cmbstatus.Text
cel.Offset(-1, 2) = txtday
'etc
Re: Form data excel sheet - yeah i know whats new!
Awesome works like a charm! thanks again!