Macro to allow user to automate combining pricing

KlayontKress

Board Regular
Joined
Jan 20, 2016
Messages
67
Office Version
  1. 2016
Platform
  1. Windows
To all,


I'm looking for a macro that will reduce a lot of tedious manual calculating. We have a program that exports pricing for customers, but the pricing comes out as individual options that are normally purchased together. The customer wants to see these values combined which is resulting in all of the manual work to do this. What we have to do is add the Add on price to the Base, Option 1, Option 2, Option 3, etc.. What I'd like to be able to do is have a macro to prompt the user for the values to add to the rest of the items (column E), and then prompt the user to select the columns to add this value to (columns D, F, G, H Below). Then the macro would add the values in column E to the items in the respective rows for columns D, F, G, H, etc.




AB
C

D
EFGH
1BaseAdd on 1Option 2Option 3Option 4
2Product 1305405060
3Product 26011708090
4Product 39015100110120
5
6new values after macro runs
7355455565
87111718191
910515115125135
10
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
if your first number is in D2 then this working.
I limit numbers between 0 to 54, you can change it.
VBA Code:
Sub AddValuesToProducts()
Dim a As Long
Dim b As Long
Dim c As Long
Dim i As Long


Application.ScreenUpdating = False
 
 Do
  a = Application.InputBox(Prompt:="Input Values to add Product1", Default:="Enter only number between 0 and 54 here", Type:=1)
 If Not IsNumeric(a) Then
    MsgBox "You must enter a numerical value."
 
    ElseIf a < 0 Or a > 54 Then
    MsgBox "Only between 0 and 54 may be added."
 End If
 Loop Until a > 0 And a < 54
 
 Do
 b = Application.InputBox(Prompt:="Input Values to add Product2", Default:="Enter only number between 0 and 54 here", Type:=1)
 If Not IsNumeric(b) Then
    MsgBox "You must enter a numerical value."
 
    ElseIf b < 0 Or b > 54 Then
    MsgBox "Only between 0 and 54 may be added."
 End If
 Loop Until b > 0 And b < 54
 Do
 c = Application.InputBox(Prompt:="Input Values to add Product3", Default:="Enter only number between 0 and 54 here", Type:=1)
If Not IsNumeric(c) Then
    MsgBox "You must enter a numerical value."
 
    ElseIf c < 0 Or c > 54 Then
    MsgBox "Only between 0 and 54 may be added."
 End If
 
Loop Until c > 0 And c < 54

Range("E2").Value = a
Range("E3").Value = b
Range("E4").Value = c

For i = 4 To 8
Cells(2, i).Value = a + Cells(2, i).Value
Cells(3, i).Value = b + Cells(3, i).Value
Cells(4, i).Value = c + Cells(4, i).Value
If i = 4 Then
i = i + 1
End If

Next i

Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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