Need help with userform vba

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,835
Office Version
365
Platform
Windows
Glad it's working & thanks for the feedback
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
102
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:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,835
Office Version
365
Platform
Windows
Which line gives the error?
 

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
102
.Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", Iff("Transfered To Holding Area", "Waste Stock"))
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,835
Office Version
365
Platform
Windows
Try
Code:
.Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", IIf(Me.Opt_TransferStock, "Transfered To Holding Area", "Waste Stock"))
 

Watch MrExcel Video

Forum statistics

Threads
1,102,665
Messages
5,488,179
Members
407,630
Latest member
Mehezabin

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top