Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
I`ve created this code but when i run it nothing happens?
I think these 2 Dims should match to run the code is this right
I think these 2 Dims should match to run the code is this right
VBA Code:
LBRow = CRow
VBA Code:
Sub Group_PartNos()
Dim ws As Worksheet
Dim Rng As Range
Dim ERow, CRow, FBRow, LBRow As Long
Dim CRValue, NRValue As String
Application.ScreenUpdating = False
Set ws = ActiveSheet
ERow = Range("C2").End(xlDown).Row
Set Rng = ws.Range("C2:C" & ERow)
FBRow = 0
LBRow = 0
For CRow = 2 To ERow
CRValue = Cells(CRow, Rng.Column).Value
NRValue = Cells(CRow + 1, Rng.Column).Value
If Not (IsEmpty(CRValue) Or CRValue = "") Then
If Not (IsEmpty(NRValue) Or NRValue = "") Then
FBRow = CRow + 1
End If
ElseIf (IsEmpty(CRValue) Or CRValue = "") Then
If Not (IsEmpty(NRValue) Or NRValue = "") Then
If FBRow = CRow <> 0 Then
LBRow = CRow
End If
End If
End If
If FBRow <> 0 And LBRow <> 0 Then
If Not ws.Rows(CurrentRow).OutlineLevel > 1 Then
ws.Range(Cells(FBRow, Rng.Column), Cells(LBRow, Rng.Column)).EntireRow.Select
Selection.Group
End If
FBRow = 0: LBRow = 0
End If
Next
Application.ScreenUpdating = True
End Sub