Need help with userform vba
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Need help with userform vba
Thanks Thanks: 0 Likes Likes: 0

  1. #11
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,638
    Post Thanks / Like
    Mentioned
    445 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Need help with userform vba

    Glad it's working & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  2. #12
    Board Regular
    Join Date
    Feb 2019
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with userform vba

    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:
    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
    
    Last edited by Fluff; Jul 18th, 2019 at 10:58 AM. Reason: code tags

  3. #13
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,638
    Post Thanks / Like
    Mentioned
    445 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Need help with userform vba

    Which line gives the error?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  4. #14
    Board Regular
    Join Date
    Feb 2019
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with userform vba

    .Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", Iff("Transfered To Holding Area", "Waste Stock"))

  5. #15
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,638
    Post Thanks / Like
    Mentioned
    445 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Need help with userform vba

    Try
    Code:
    .Range("D" & NewRow).Value = IIf(Me.opt_AddStock.Value, "Added To Warehouse", IIf(Me.Opt_TransferStock, "Transfered To Holding Area", "Waste Stock"))
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •