A
Alan Smith
I am trying to design a user form to allow department managers to add new
employee details, or adjustments to existing employees. The form has a number
of fields to be filled, either combo box or text box, but I'm getting the
above error when I test it. I haven't used VB a lot, and am trying to build
on some examples I found to create this. Here's the code - any ideas?
Thanks,
Alan
Private Sub UserForm_Initialize()
Dim cManager As Range
Dim cRegion As Range
Dim cUnit As Range
Dim cHierarchy As Range
Dim cExpense As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")
For Each cManager In ws.Range("ManagerList")
With Me.cboManager
.AddItem cManager.Value
.List(.ListCount - 1, 1) = cManager.Offset(0, 1).Value
End With
Next cManager
Me.txtEmployee.Value = "Enter Name"
For Each cRegion In ws.Range("RegionList")
With Me.cboRegion
.AddItem cRegion.Value
.List(.ListCount - 1, 1) = cRegion.Offset(0, 1).Value
End With
Next cRegion
For Each cUnit In ws.Range("UnitList")
With Me.cboUnit
.AddItem cUnit.Value
.List(.ListCount - 1, 1) = cUnit.Offset(0, 1).Value
End With
Next cUnit
For Each cHierarchy In ws.Range("HierarchyList")
With Me.cboHierarchy
.AddItem cHierarchy.Value
.List(.ListCount - 1, 1) = cHierarchy.Offset(0, 1).Value
End With
Next cHierarchy
Me.txtAllocation.Value = "Enter Percentage"
For Each cExpense In ws.Range("ExpenseList")
With Me.cboExpense
.AddItem cExpense.Value
.List(.ListCount - 1, 1) = cExpense.Offset(0, 1).Value
End With
Next cExpense
Me.txtCurrency.Value = "Enter Currency"
Me.txtAmount.Value = 1
Me.txtDate.Value = Format(txtDate, "mm/dd/yyyy")
Me.txtComment.Value = "Enter Comments"
Me.cboManager.SetFocus
End Sub
employee details, or adjustments to existing employees. The form has a number
of fields to be filled, either combo box or text box, but I'm getting the
above error when I test it. I haven't used VB a lot, and am trying to build
on some examples I found to create this. Here's the code - any ideas?
Thanks,
Alan
Private Sub UserForm_Initialize()
Dim cManager As Range
Dim cRegion As Range
Dim cUnit As Range
Dim cHierarchy As Range
Dim cExpense As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")
For Each cManager In ws.Range("ManagerList")
With Me.cboManager
.AddItem cManager.Value
.List(.ListCount - 1, 1) = cManager.Offset(0, 1).Value
End With
Next cManager
Me.txtEmployee.Value = "Enter Name"
For Each cRegion In ws.Range("RegionList")
With Me.cboRegion
.AddItem cRegion.Value
.List(.ListCount - 1, 1) = cRegion.Offset(0, 1).Value
End With
Next cRegion
For Each cUnit In ws.Range("UnitList")
With Me.cboUnit
.AddItem cUnit.Value
.List(.ListCount - 1, 1) = cUnit.Offset(0, 1).Value
End With
Next cUnit
For Each cHierarchy In ws.Range("HierarchyList")
With Me.cboHierarchy
.AddItem cHierarchy.Value
.List(.ListCount - 1, 1) = cHierarchy.Offset(0, 1).Value
End With
Next cHierarchy
Me.txtAllocation.Value = "Enter Percentage"
For Each cExpense In ws.Range("ExpenseList")
With Me.cboExpense
.AddItem cExpense.Value
.List(.ListCount - 1, 1) = cExpense.Offset(0, 1).Value
End With
Next cExpense
Me.txtCurrency.Value = "Enter Currency"
Me.txtAmount.Value = 1
Me.txtDate.Value = Format(txtDate, "mm/dd/yyyy")
Me.txtComment.Value = "Enter Comments"
Me.cboManager.SetFocus
End Sub