Prasad,
Here are a couple of examples. Test1 evaluates the current selection on the
worksheet. Test2 can be used to find if a given cell address is part of a
merged cell range. I used the RowAbsolute and ColumnAbsolute parameters to
remove the "$" from the cell address (i.e. $A$1:$A$7 ==> A1:A7).
Troy
Sub Test1()
Dim rng1 As Range
If TypeName(Selection) = "Range" Then
Set rng1 = Selection
If Selection.MergeCells = True Then
Debug.Print "Merged = " & rng1.MergeCells
Debug.Print "Cell Count = " & rng1.Count
Debug.Print "Row Count = " & rng1.Rows.Count
Debug.Print "Column Count = " & rng1.Columns.Count
Debug.Print "Address = " & rng1.Address( _
RowAbsolute:=False, _
ColumnAbsolute:=False)
Else
Debug.Print "Selection not merged"
End If
End If
End Sub
Sub Test2()
Dim rng1 As Range
Dim rng2 As Range
'''Example: Merged cells are: A1:A7 on Sheet1.
Set rng1 = Sheet1.Range("A3")
Set rng2 = rng1.MergeArea
If rng2.MergeCells = True Then
Debug.Print rng2.Address( _
RowAbsolute:=False, _
ColumnAbsolute:=False)
Else
Debug.Print "Cell not merged"
End If
End Sub