Free Republic
Browse · Search
General/Chat
Topics · Post Article

To: Chad C. Mulligan

Hmmmm. They must not like antivirals and VPNs


29 posted on 04/08/2023 4:13:11 PM PDT by null and void (I'm ready to come back to Russia but I don’t want to live in a country that starts wars ~ Diuzharden)
[ Post Reply | Private Reply | To 28 | View Replies ]


To: null and void

Check this out:

Rooster: Can you write me a VBA routine for a sorting a single column of numbers from low to high and sort all data in connected cells on a line by line basis and add an empty line between those numbers which are equal to each other

ChatGPT: Certainly! Here is a VBA routine that sorts a single column of numbers from low to high and sorts all data in connected cells on a line-by-line basis, and then adds an empty line between those numbers which are equal to each other:

Sub SortAndAddEmptyLine()
Dim lastRow As Long
Dim currentNum As Double
Dim nextNum As Double
Dim i As Long

’ Find the last row of the data in the column to be sorted
lastRow = Cells(Rows.Count, “A”).End(xlUp).Row

’ Sort the column of numbers from low to high
Range(”A1:A” & lastRow).Sort Key1:=Range(”A1”), Order1:=xlAscending, Header:=xlNo

’ Sort all data in connected cells on a line-by-line basis
For i = 1 To lastRow
Cells(i, 1).Resize(1, Columns.Count - 1).Sort _
Key1:=Cells(i, 1), Order1:=xlAscending, Header:=xlNo
Next i

’ Add an empty line between those numbers which are equal to each other
For i = lastRow To 2 Step -1
currentNum = Cells(i, 1).Value
nextNum = Cells(i - 1, 1).Value

’ If the current number is equal to the next number, insert an empty line between them
If currentNum = nextNum Then
Cells(i, 1).EntireRow.Insert shift:=xlDown
End If
Next i
End Sub


30 posted on 04/08/2023 4:20:07 PM PDT by RoosterRedux (Bonhoeffer: “Silence in the face of evil is evil. Not to speak is to speak. Not to act is to act.”)
[ Post Reply | Private Reply | To 29 | View Replies ]

Free Republic
Browse · Search
General/Chat
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson