Hi,
I set up a macro before to add a blank row for each group of values. I now try to do the similar but cannot succeed. I can do it with a 2-step macro or 2 macros. But I'm not satisfied so still trying to do it with one step.
Here is the code that's not working. It works on the first a few rows but fails for the rest.
Any suggestions?
Here is part of the data.
terr family sites
ON1L0102 AK10005 1
ON1C0506 AL11006 1
ON1C0504 AL11040 1
ON1C0506 AL11042 2
ON1C0506 AL11042 2
ON1C0503 AL11043 3
ON1C0503 AL11043 3
ON1C0503 AL11043 3
ON1C0506 AL11044 4
ON1C0504 AL11044 4
ON1C0506 AL11044 4
ON1C0504 AL11044 4
....... .........
Thanks in advance.
Sub AddLinesBasedOnGroup(Col As String) 'nw
Range(Col & 2).Activate
While ActiveCell <> ""
While ActiveCell = ActiveCell.Offset(1)
ActiveCell.Offset(1).Activate
Wend
If ActiveCell <> ActiveCell.Offset(1) Then
ActiveCell.EntireRow.Select
MsgBox ActiveCell.Address
' With Selection.Borders(xlEdgeBottom)
' .LineStyle = xlContinuous
' .ColorIndex = 0
' .TintAndShade = 0
' .Weight = xlThin
' End With
End If
ActiveCell.Offset(1).Activate
Wend
End Sub
Sub tnt()
AddLinesBasedOnGroup "b"
End Sub
I set up a macro before to add a blank row for each group of values. I now try to do the similar but cannot succeed. I can do it with a 2-step macro or 2 macros. But I'm not satisfied so still trying to do it with one step.
Here is the code that's not working. It works on the first a few rows but fails for the rest.
Any suggestions?
Here is part of the data.
terr family sites
ON1L0102 AK10005 1
ON1C0506 AL11006 1
ON1C0504 AL11040 1
ON1C0506 AL11042 2
ON1C0506 AL11042 2
ON1C0503 AL11043 3
ON1C0503 AL11043 3
ON1C0503 AL11043 3
ON1C0506 AL11044 4
ON1C0504 AL11044 4
ON1C0506 AL11044 4
ON1C0504 AL11044 4
....... .........
Thanks in advance.
Sub AddLinesBasedOnGroup(Col As String) 'nw
Range(Col & 2).Activate
While ActiveCell <> ""
While ActiveCell = ActiveCell.Offset(1)
ActiveCell.Offset(1).Activate
Wend
If ActiveCell <> ActiveCell.Offset(1) Then
ActiveCell.EntireRow.Select
MsgBox ActiveCell.Address
' With Selection.Borders(xlEdgeBottom)
' .LineStyle = xlContinuous
' .ColorIndex = 0
' .TintAndShade = 0
' .Weight = xlThin
' End With
End If
ActiveCell.Offset(1).Activate
Wend
End Sub
Sub tnt()
AddLinesBasedOnGroup "b"
End Sub