ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Output array to Excel blank rows separating groups (https://www.excelbanter.com/excel-programming/354776-output-array-excel-blank-rows-separating-groups.html)

ghh3rd

Output array to Excel blank rows separating groups
 

I've got an array which I'd like to group while writing it to Excel b
inserting a blank row above (and below) any groups of repeating value
in Col "A". Determining the locations for the bottom blank row i
easy, it's the top row that I'm having a problem with.

Any tips? Here's my test code to replicate what I want to do:



Code
-------------------
Function tester()
Dim IDCount
Dim IDHold
Dim i
IDCount = 0
IDHold = ""
Dim ID
Dim IDS As Variant

ID = ""
IDS = Array("A", "A", "B", "B", "C", "D", "E", "F", "F", "G")

For i = 1 To 10
ID = IDS(i)
'IDCount = IDCount + 1
If ID < IDHold Then
If IDCount 1 Then
'MsgBox "EXTRA ROW INSERTED"
Debug.Print ""
IDCount = 0
End If
End If
Debug.Print "ID: " & ID & " " & "IDHOLD: " & IDHold & " " & "IDCOUNT: " & IDCount
IDHold = ID
IDCount = IDCount + 1
Next i
End Function
-------------------



Thanks,

Rand

--
ghh3r
-----------------------------------------------------------------------
ghh3rd's Profile: http://www.excelforum.com/member.php...fo&userid=3204
View this thread: http://www.excelforum.com/showthread.php?threadid=51797



All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com