Need help with userform vba

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
172
Hi, I have created a userform with 2 option buttons, 1 combobox and 2 textboxes, I also have 2 sheets Transfers and Master, if I select the add stock option button and fill out the rest of the form and click submit it adds stock in the master sheet column C which works fine the part I can not figure out is how to transfer stock with the other option button I need it to add the amount to column D then minus it from colum C. There is a link below with the file which will make more sense.

https://www.dropbox.com/s/8eln30oauh05p6i/Test_1.xlsm?dl=0

Regards
 
Glad it's working & thanks for the feedback
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,

I have added another optionbox to my userform (opt_WasteStock) and tried to update the vba with no luck as I am very new to this, I'm am getting a compile error: wrong number of arguments or invalide property assignment.

I need the value to minus from sheet IngMaster column D.

Code:
[FONT=Verdana]Private Sub CommandButton1_Click()
    Dim NewRow As Long
    Dim m As Variant
    
    If Not Me.opt_AddStock And Not Me.opt_TransferStock And Not Me.opt_WasteStock Then
      MsgBox "please select Add Stock, Transfer Stock or Waste Stock"
      Exit Sub
   End If
    Application.DisplayAlerts = False
    
    With wsTransfers
        NewRow = .Range("A" & .Rows.count).End(xlUp).Row + 1
        .Range("A" & NewRow).Value = Me.ComboBox1.Text
        .Range("B" & NewRow).Value = Me.TextBox1.Text
        .Range("C" & NewRow).Value = Me.TextBox2.Text
        .Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", Iff("Transfered To Holding Area", "Waste Stock"))
        .Range("E" & NewRow).Value = Now
    End With
'update Ingmaster
    With wsIngMaster
        m = Application.Match(Val(Me.ComboBox1.Text), .Columns(1), 0)
        If Not IsError(m) Then
            With .Cells(CLng(m), "C")
               If Me.opt_AddStock Then
                  .Value = .Value + Val(Me.TextBox2.Value)
               ElseIf Me.opt_TransferStock Then
                  .Offset(, 1).Value = .Offset(, 1).Value + Val(Me.TextBox2.Value)
                  .Value = .Value - Val(Me.TextBox2.Value)
                  ElseIf Me.opt_WasteStock Then
                  .Offset(, 1).Value = .Offset(, 1).Value + Val(Me.TextBox2.Value)
                  .Value = .Value - Val(Me.TextBox2.Value)
    Application.DisplayAlerts = True
               End If
               End With
            End If
            End With
        End If
    End With
    Unload Me
    frm_Stock.Show
End Sub
[/FONT]
 
Last edited by a moderator:
Upvote 0
.Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", Iff("Transfered To Holding Area", "Waste Stock"))
 
Upvote 0
Try
Code:
.Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", IIf(Me.Opt_TransferStock, "Transfered To Holding Area", "Waste Stock"))
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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