lundi 24 octobre 2016

Nested IF statements VBA

I have the below code which works fine for importing data from one sheet to another via a simple loop code.

            Dim y As Integer
            y = 15
            For X = 15 To LR Step 1
            If Len(WS.Range("B" & X)) >= 7 Then
                WS.Range("B" & X).Copy
                WS1.Range("E" & y).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False

            y = y + 1
            Else
            End If
            Next X

I would like to add an IF statement that if the LEN is greater than 7 sum all the above values up until the last time a value was greater than 7 len and group the values so they can be collapsed into a subtotal.

I imagine this would be a IF statement nested into my current code but unsure of how I would reference the points.

Added pictures to help explain what I currently have and what I would like to achieve with your help.enter image description here

Aucun commentaire:

Enregistrer un commentaire