Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Macro question
Hello, I have a spreadsheet that is supposed to have four entries for
each name. More often than not, it has 1, 2, or 3. I need a macro that will find like entries in a column, count them, and if they do not equal four, I need enough blank rows to equal four. Is it possible? Thanks! Example: Have: Doe, John Eye, Pop Eye, Pop Finch, Atticus Finch, Atticus Finch, Atticus Normal, Abby Normal, Abby Normal, Abby Normal, Abby Need: Doe, John Eye, Pop Eye, Pop Finch, Atticus Finch, Atticus Finch, Atticus Normal, Abby Normal, Abby Normal, Abby Normal, Abby |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Macro question
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit Dim i As Long Dim iLastRow As Long Dim cRows As Long With ActiveSheet iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row For i = iLastRow To 1 Step -1 cRows = Application.CountIf(.Columns(1), .Cells(i, TEST_COLUMN).Value) If cRows < 4 Then .Rows(i + 1).Resize(4 - cRows).Insert End If i = i - cRows + 1 Next i End With End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ups.com... Hello, I have a spreadsheet that is supposed to have four entries for each name. More often than not, it has 1, 2, or 3. I need a macro that will find like entries in a column, count them, and if they do not equal four, I need enough blank rows to equal four. Is it possible? Thanks! Example: Have: Doe, John Eye, Pop Eye, Pop Finch, Atticus Finch, Atticus Finch, Atticus Normal, Abby Normal, Abby Normal, Abby Normal, Abby Need: Doe, John Eye, Pop Eye, Pop Finch, Atticus Finch, Atticus Finch, Atticus Normal, Abby Normal, Abby Normal, Abby Normal, Abby |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 Macro/VB Question DDE Question | Excel Worksheet Functions | |||
Excel macro question | Excel Discussion (Misc queries) | |||
Excel Macro question | Excel Discussion (Misc queries) | |||
Excel Macro Question? | Excel Programming | |||
Excel Macro Question | Excel Worksheet Functions |