Complicated User Form

mayrose

New Member
Joined
Sep 21, 2009
Messages
1
I am familiar with Excel, but am very new to the VBA Language, but am creating a UserForm that has complicated commands for Macros to carry out. The following is what I need my workbook to do. I wrote it in plain text and hope that it makes sense. Thank you for any help or direction you can give me!!!

Activate Inventory Sheet
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Selection Made From Combo Box on user form:
<o:p> </o:p>
If Cycle Item1 is selected, Data goes into row 5 (Constant)
If Cycle Item2 is selected, Data goes into row6 (Constant)
If Cycle Item3 is selected, Data goes into row7 (Constant)
<o:p> </o:p>
Value Input into Textbox on User Form:
<o:p> </o:p>
BegInv Textbox value goes into column D
Receipts Textbox Value goes into column E
Adjust In Textbox Value goes into column F
Adjust Out Textbox Value goes into column G
<o:p> </o:p>
Selection Made from Combo Box on User Form
<o:p> </o:p>
If Monday, Regular Hours selected, Product Volume Textbox Value goes into ColumnH: Number of Hours Textbox Value goes into ColumnI
If Monday, Overtime Hours selected, Product Volume Textbox Value goes into ColumnJ: Number of Hours Textbox Value goes into ColumnK
If Monday, Part Time Extra Hours selected, Product Volume Textbox Value goes into ColumnL: Number of Hours Textbox Value goes into ColumnM
If Tuesday, Regular Hours selected, Product Volume Textbox Value goes into ColumnN: Number of Hours Textbox Value goes into ColumnO
If Tuesday, Overtime Hours selected, Product Volume Textbox Value goes into ColumnP: Number of Hours Textbox Value goes into ColumnQ
If Tuesday, Part Time Extra Hours selected, Product Volume Textbox Value goes into ColumnR: Number of Hours Textbox Value goes into ColumnS
If Wednesday, Regular Hours selected, Product Volume Textbox goes into ColumnT: Number of Hours Textbox Value goes into ColumnU
If Wednesday, Overtime Hours selected, Product Volume Textbox goes into ColumnV: Number of Hours Textbox Value goes into ColumnW
If Wednesday, Part Time Extra Hours selected, Product Volume Textbox Value goes into ColumnX: Number of Hours Textbox Value goes into ColumnY
If Thursday, Regular Hours selected, Product Volume Textbox Value goes into ColumnZ: Number of Hours Textbox Value goes into ColumnAA
If Thursday, Overtime Hours selected, Product Volume Textbox Value goes into ColumnAB: Number of Hours Textbox Value goes into ColumnAC
If Thursday, Part Time Extra Hours selected, Product Volume Textbox Value goes into ColumnAD: Number of Hours Textbox Value goes into ColumnAE
If Friday, Regular Hours selected, Product Volume Textbox Value goes into Column AF: Number of Hours Textbox Value goes into Column AG
If Friday, Overtime Hours selected, Product Volume Textbox Value goes into Column AH: Number of Hours Textbox Value goes into Column AI
If Friday, Part Time Hours selected, Product Volume Textbox Value goes into Column AJ: Number of Hours Textbox Value goes into <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:place w:st="on"><st1:City w:st="on">Column</st1:City> <st1:State w:st="on">AK</st1:State></st1:place>
If Saturday, Overtime Hours selected, Product Volume Textbox Value goes into Column AL: Number of Hours Textbox value goes into Column AM
If Saturday, Part Time Extra Hours selected, Product Volume Textbox Value goes into ColumnAN: Number of Hours Textbox Value goes into Column AO.
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Give this code a try. It makes the following assumptions:
  • The name of your inventory worksheet is "Inventory" (you may change that by assigning a different string value to the constant INVENTORYSHEET
  • You copy the code into the VBA modules associated with the UserForm you created
  • This UserForm has two ComboBoxes, named 'ComboBox_Cycle' and 'ComboBox_Hours'
  • The UserForm has the following TextBoxes:
    • TextBox_BegInv
    • TextBox_Receipts
    • TextBox_AdjustIn
    • TextBox_AdjustOut
    • TextBox_ProductVolume
    • TextBox_ProductVolume
  • The UserForm has a CommandButton named 'cmdBtn_OK'
Code:
Const INVENTORYSHEET = "Inventory"
Private Sub cmdBtn_OK_Click()
 
    Dim targetRow As Long
    targetRow = ComboBox_Cycle.ListIndex + 5
 
    Sheets(INVENTORYSHEET).Cells(targetRow, "D").Value = TextBox_BegInv.Text
    Sheets(INVENTORYSHEET).Cells(targetRow, "E").Value = TextBox_Receipts.Text
    Sheets(INVENTORYSHEET).Cells(targetRow, "F").Value = TextBox_AdjustIn.Text
    Sheets(INVENTORYSHEET).Cells(targetRow, "G").Value = TextBox_AdjustOut.Text
    Dim targetColumn As Integer
    targetColumn = 2 * ComboBox_Hours.ListIndex + 8
 
    Sheets(INVENTORYSHEET).Cells(targetRow, targetColumn).Value = TextBox_ProductVolume.Text
    Sheets(INVENTORYSHEET).Cells(targetRow, targetColumn + 1).Value = TextBox_ProductVolume.Text
 
End Sub
Private Sub UserForm_Activate()
 
    Sheets(INVENTORYSHEET).Activate
 
    'Populate ComboBoxes
 
    ComboBox_Cycle.Clear
    ComboBox_Cycle.AddItem ("Cycle Item 1")
    ComboBox_Cycle.AddItem ("Cycle Item 2")
    ComboBox_Cycle.AddItem ("Cycle Item 3")
    ComboBox_Cycle.ListIndex = 0
 
    ComboBox_Hours.Clear
    Dim iDay As Integer
    For iDay = 1 To 6
        Dim strWeekDayName As String
        strWeekDayName = weekDayName(iDay, False, vbMonday)
        If strWeekDayName <> "Saturday" Then ComboBox_Hours.AddItem (strWeekDayName & ", Regular Hours")
        ComboBox_Hours.AddItem (strWeekDayName & ", Overtime Hours")
        ComboBox_Hours.AddItem (strWeekDayName & ", Part Time Extra Hours")
    Next iDay
    ComboBox_Hours.ListIndex = 0
 
End Sub

Hope this helped,
Rolf Jaeger
SoarentComputing
http://soarentcomputing.com

Phone: 800.580.0068
Cell: 510.300.7462
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top