View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
CG Rosén CG Rosén is offline
external usenet poster
 
Posts: 74
Default "Split Unioned Ranges"





Good Day Group,

Is there another way to "split" the "result" -variable from the code below
into variables of type:
r = Range("C2:F2") etc.
With my limited knowledge I can only think of do it with Len and Mid
functions.

Brgds

CG Rosén
---------------------------------------------------------------
Dim rng As Range, cell As Range
Dim rngList() As Range, i As Long

For Each cell In Rows(3).Cells
If cell.Interior.ColorIndex = 15 Then
If rng Is Nothing Then
Set rng = cell
Else
Set rng = Union(rng, cell)
End If
End If
Next

If Not rng Is Nothing Then
result = rng.Address(RowAbsolute:=False, ColumnAbsolute:=False)
End If

MsgBox result