Hi All

I know the subject title is a little vague.

I have the following code which works relatively well, with the exception 
of the summing of the split total.

So Column G which may have up to 30 rows and only has 4 values (A, B, C, or 
D) which this code inserts rows separating these differing values.

This newly inserted Row Is then coloured Blue between Columns A to L.

It is supposed to then sum the values of I, J & K in the newly inserted 
Blue Line.

The issue.

The first bracket of rows with the A Value, regardless if it is 1 row or 10 
does not sum correctly, although each of the ensuing brackets do sum 
correctly.

Sub dcBreaks()

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

For col = 1 To 12

Select Case Sheets("" & ActiveSheet.Name).Cells(1, col).Value
Case "DEST"
myDC = col
Case "STACKS"
myStacks = col
Case "WEIGHT"
myWeight = col
Case "WOODS"
myWoods = col
End Select

Next col

For i = 2 To 50

 myDC = Cells(i, "G").Value
  If myDC <> Cells(i + 1, "G").Value Then
   Rows(i + 1 & ":" & i + 1).Select
    Selection.Insert shift:=xlDown

     Range(Cells(i + 1, 1), Cells(i + 1, 12)).Select
     Selection.Interior.ColorIndex = 37
     Selection.Font.Bold = True

     myStacks = myStacks + Cells(i, "H").Value
     myWeight = myWeight + Cells(i, "I").Value
     myWoods = myWoods + Cells(i, "J").Value

     Cells(i + 1, "H").Value = myStacks
     Cells(i + 1, "I").Value = myWeight
     Cells(i + 1, "J").Value = myWoods
     myStacks = 0
     myWeight = 0
     myWoods = 0

   i = i + 1

     ElseIf myDC = Cells(i, "G").Value Then

     myStacks = myStacks + Cells(i, "H").Value
     myWeight = myWeight + Cells(i, "I").Value
     myWoods = myWoods + Cells(i, "J").Value

   End If

Next I

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With

End Sub

Any thoughts appreciated.

TIA
Mark

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at https://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to