+ Reply to Thread
Results 1 to 16 of 16

add & subtract values from userform to specific column in sheet

Hybrid View

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: add & subtract values from userform to specific column in sheet

    For add userform use below...For subtract userform use same but change red + to -

    Private Sub CommandButton1_Click()
    Dim Chk, i As Long, x As Long, nr As Long: x = 1
    Dim Cb1 As String, Cb2 As String, Cb3 As String, Cb4 As String
    With sheet1
        nr = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
        For i = 1 To 2
            With .Cells(1).CurrentRegion
                Cb1 = Me.Controls("ComboBox" & x): Cb2 = Me.Controls("ComboBox" & x + 1): Cb3 = Me.Controls("ComboBox" & x + 2): Cb4 = Me.Controls("ComboBox" & x + 3)
                Chk = Evaluate("=MATCH(""" & Cb1 & """ & """ & Cb2 & """& """ & Cb3 & """& """ & Cb4 & """," & .Columns(1).Address & "&" & .Columns(2).Address & "&" & .Columns(3).Address & "&" & .Columns(4).Address & ",0)")
            End With
            If Not IsError(x) Then
                .Cells(Chk, 5) = .Cells(Chk, 5) + Me.Controls("TextBox" & i)
            Else
                .Range("A" & nr).Resize(, 5) = Array(Cb1, Cb2, Cb3, Cb4, Me.Controls("TextBox" & i).Value)
            End If
            x = 5
        Next i
    End With
    End Sub
    Last edited by Sintek; 09-12-2020 at 12:48 PM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA to Search for Multiple Values in a column on a specific sheet
    By LKERN in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-31-2019, 04:14 PM
  2. vba to subtract two column values and add new too if added in second sheet
    By ROHAN999 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-18-2018, 03:02 PM
  3. [SOLVED] How to return specific column values in a separate sheet
    By MyStix01 in forum Excel General
    Replies: 7
    Last Post: 06-29-2018, 12:43 AM
  4. Subtract values without change value in specific cell
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2017, 03:34 PM
  5. [SOLVED] Subtract two date colums and count rows with specific values
    By waylynjohnston1 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-06-2016, 06:45 PM
  6. VBA UserForm - Contact sheet; Using a ComboBox array to write data to specific column
    By willmason in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2014, 09:44 AM
  7. [SOLVED] Populate summary sheet with values within specific month column on data sheet...
    By blue91 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-12-2013, 12:11 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1