Keebler
Board Regular
- Joined
- Dec 1, 2021
- Messages
- 176
- Office Version
- 2021
- Platform
- Windows
so with the blanks (empty rows) conundrum solved, moving on to the next area
so, here is the working copy of the vba code from post 67
so this thread is adding a sort feature for the 3 columns
they all need to be sorted alphabetically, but separately (of course)
the columns to be sorted column A, Q, and AG
the rows are a3: end of column; q3: end of column ag3:end of column
ive had some success with doing the sorting manually, but as one might notice quickly. it get tedious after a bit.
especially when all this needs to run every time the data fields are updated
so, here is the working copy of the vba code from post 67
VBA Code:
Sub copyto_test_REMOVEBLANKS_b18() 'working (by Shina67)
Dim sourceWS As Worksheet
Dim destinationWS As Worksheet
Dim sourceRange As Range
Dim destinationRange As Range
Dim lastRow As Long
Dim i As Long, J As Long
Dim destinationLastRow As Long
Dim emptyRow As Boolean
Set sourceWS = ThisWorkbook.Sheets("INDEX")
Set destinationWS = ThisWorkbook.Sheets("INDEX2")
lastRow = sourceWS.Cells(sourceWS.Rows.Count, "A").End(xlUp).row
Set sourceRange = sourceWS.Range("A3:aq" & lastRow)
destinationWS.Cells.Clear
For i = 1 To sourceRange.Rows.Count
emptyRow = True
For J = 1 To sourceRange.Columns.Count
If sourceRange.Cells(i, J).Value <> "" Then 'Alex B
emptyRow = False
Exit For
End If
Next J
If Not emptyRow Then
If Not destinationRange Is Nothing Then
Set destinationRange = Union(destinationRange, sourceRange.Rows(i))
Else
Set destinationRange = sourceRange.Rows(i)
End If
End If
Next i
destinationLastRow = destinationWS.Cells(destinationWS.Rows.Count, "A").End(xlUp).row
If Not destinationRange Is Nothing Then
If destinationLastRow > 0 Then
destinationRange.Copy destinationWS.Cells(destinationLastRow + 1, "A")
Else
destinationRange.Copy destinationWS.Range("A3")
End If
End If
destinationWS.Range("a2").EntireRow.Insert 'adds a empty row to the top of the output page (well row 2)
End Sub
so this thread is adding a sort feature for the 3 columns
they all need to be sorted alphabetically, but separately (of course)
the columns to be sorted column A, Q, and AG
the rows are a3: end of column; q3: end of column ag3:end of column
ive had some success with doing the sorting manually, but as one might notice quickly. it get tedious after a bit.
especially when all this needs to run every time the data fields are updated