Sorting, Adding cost values for each input, Deleting row & writing a total

JeremyA1976

Board Regular
Joined
Aug 3, 2015
Messages
59
I have 7 columns that contain data. In column A, there can be identical descriptions for each input. In column K, there is a total cost for that row entry. In column N, I have quantities (if applicable) for each entry. I have the sort vba code figured out as such...

Sub UnMerge4Sort()



'UNMERGES CELLS, SORTS BY COLUMN A & FORMAT PAINTS ROW 9 DOWN
Application.ScreenUpdating = False


Range("A10:P58").Select
ActiveWindow.SmallScroll Down:=-48

Selection.UnMerge
ActiveWorkbook.Worksheets("CHARGE OUT FORM").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CHARGE OUT FORM").Sort.SortFields.Add Key:=Range( _
"A10:A58"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("CHARGE OUT FORM").Sort
.SetRange Range("A10:P58")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A9:P9").Select
Selection.Copy
Range("A10:P58").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Application.ScreenUpdating = True

End Sub


I have merged cells, so it simply unmerges, sorts based on column A in ascending order, then formats the unmerged cells back to normal based on row 9 format. What I am having trouble with is figuring out how to combine identical rows and sum their square footage (column G), pounds (column I), cost (Column K) & quantity (column N). The code would have to:
1.) figure out which rows are identical based on column A.
2.) Sum columns G,I,K & N.
3.) Place it in memory or in a hidden cell to recall and write.
4.) Delete the original identical rows information.
5.) Write in one row that would include the new total sums.
6.) Then search for the next identical

EXAMPLE:

column A
Material Description
column G
Sq./Ft. or Lin.Ft.
column I
LBS.
column K
Cost
column M
ACT
column N
QTY
1" INSULATION 1 1/2 LB150 64.512-60-
1" INSULATION 1 1/2 LB550 236.512-60-
2 1/2" STICK PINS 32.512-60250
2 1/2" STICK PINS 1312-60100
2x2x3/16" ANGLE3073.238.0612-40-
2x2x3/16" ANGLE150366190.3212-40-

<colgroup><col span="11"><col><col><col></colgroup><tbody>
</tbody>



Essentially, I would be replacing multiple rows with one row which would have the totals (mentioned above). Is this even possible?? If someone could just help point me in the right direction, I would appreciate it.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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