View Single Post
 
Old 05-01-2012, 07:47 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,344
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Here's a macro for processing the data in Excel. If the number of columns is liable to vary as you suggest, the simplest solution would be to have the status data as the second field, with the group IDs as the first field. The macro would need some minor re-coding for that, but that's a lot easier than coding for variable column counts, especially if the number of columns per row varies.
Code:
Sub UpdateGroupFlags()
Application.ScreenUpdating = False
Dim I As Long, LastRow As Long, strGrp As String, strStatus As String
LastRow = Worksheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell).Row
With Worksheets("Sheet1")
  .Range("A1:C" & LastRow).Sort Key1:=.Columns("A"), Key2:=.Columns("C"), _
    Key2:=.Columns("B"), Order1:=xlAscending, Header:=xlNo
    For I = 2 To LastRow
      If .Range("A" & I).Value <> strGrp Then
        strGrp = .Range("A" & I).Value
        strStatus = .Range("C" & I).Value
      Else
        .Range("C" & I).Value = strStatus
      End If
    Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote