The below VBA code I am using will add new figures to the old figures by inserting a number in the popup box that appears once I enter a number I want added. IE: If the totals in pic below are 7,5,4,8 and I type in 7 it will add 7 to each column. What I want to be able to do is enter a seperate add in number for each column in that row all at the same time and then once I hit ok it will add them in to the previous numbers. (IE: If I enter 4,8,7,9, the new totals would be 11,13,11,17) This would allow me to be able to do a row at a time with different add in numbers updating those columns. As it stands now I would have to select them by themselves and then enter the number total I needed added in. Here is the test sheet.
What would I need to change in the code below in order to accomplish this?
Dim WS As Worksheet
Dim RngSel As Range
Dim Num As Double
Dim i As Long
Dim j As Long
Dim Rows As Long
Dim Cols As Long
Dim Arr() As Variant
Dim strPromp As String
Set RngSel = Selection
Rows = RngSel.Rows.Count
Cols = RngSel.Columns.Count
strPrompt = "Enter number to add to selected cells"
Num = InputBox(strPrompt, "Number to add", 7)
If RngSel.Count = 1 Then
RngSel = RngSel + Num
Else
Arr = RngSel
For i = 1 To Rows
For j = 1 To Cols
Arr(i, j) = Arr(i, j) + Num
Next j
Next i
RngSel.Value = Arr
End If
'this will input any value into any cell you wish and add it to previous total
What would I need to change in the code below in order to accomplish this?
Dim WS As Worksheet
Dim RngSel As Range
Dim Num As Double
Dim i As Long
Dim j As Long
Dim Rows As Long
Dim Cols As Long
Dim Arr() As Variant
Dim strPromp As String
Set RngSel = Selection
Rows = RngSel.Rows.Count
Cols = RngSel.Columns.Count
strPrompt = "Enter number to add to selected cells"
Num = InputBox(strPrompt, "Number to add", 7)
If RngSel.Count = 1 Then
RngSel = RngSel + Num
Else
Arr = RngSel
For i = 1 To Rows
For j = 1 To Cols
Arr(i, j) = Arr(i, j) + Num
Next j
Next i
RngSel.Value = Arr
End If
'this will input any value into any cell you wish and add it to previous total