Hi everyone,
Basically Im trying to rearrange my columns based on the array "Row Labels", "Bereavement", "Provincial Leave", "Medical Waiver". The error happens when it finds Medical Waiver and then cuts.
Not sure how to fix this or if its even the right method.
*xl2bb crashes when I capture using Mini Sheet. Row Label is A1*
Thanks for any help.
Basically Im trying to rearrange my columns based on the array "Row Labels", "Bereavement", "Provincial Leave", "Medical Waiver". The error happens when it finds Medical Waiver and then cuts.
Not sure how to fix this or if its even the right method.
Row Labels | Bereavement | Medical Waiver | Provincial Leave |
1234 | Not Used | Not Used | 7 |
1234 | Not Used | Not Used | 9 |
1234 | Not Used | Not Used | 9 |
1234 | Not Used | Not Used | 7 |
*xl2bb crashes when I capture using Mini Sheet. Row Label is A1*
VBA Code:
Sub reordercolumns()
Dim arrColOrder As Variant, ndx As Integer
Dim Found As Range, Counter As Integer, fc As Range
arrColOrder = Array("Row Labels", "Bereavement", "Provincial Leave", "Medical Waiver")
Counter = 1
For ndx = LBound(arrColOrder) To UBound(arrColOrder)
Set Found = Range("A1:D1").Find(arrColOrder(ndx), LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
If Not Found Is Nothing Then
If Found.Column <> Counter Then
Found.EntireColumn.Cut
Columns(Counter).Insert Shift:=xlToRight
Application.CutCopyMode = False
End If
Counter = Counter + 1
End If
Next ndx
End Sub
Thanks for any help.