Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Address of Merged Cells

I have merged cells from A1 to A7. When I activate the merged range th
address list shows A1. I want the the total address of the merged rang
i.e. A1:A7 through VB. (Activecell.address shows A1 ) Can anyone hel
me ?

Prasad Josh

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Address of Merged Cells

I don't think there's a direct way, but you could check the address o
the next cell and then reduce by one to get the range.

- Manges

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Address of Merged Cells

Option Explicit
Sub testme()

MsgBox ActiveSheet.Range("a1").Address
MsgBox ActiveSheet.Range("a1").MergeArea.Address

End Sub

Will return different values.

"pgjoshi <" wrote:

I have merged cells from A1 to A7. When I activate the merged range the
address list shows A1. I want the the total address of the merged range
i.e. A1:A7 through VB. (Activecell.address shows A1 ) Can anyone help
me ?

Prasad Joshi

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Address of Merged Cells

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 a 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


"pgjoshi " wrote in message
...
I have merged cells from A1 to A7. When I activate the merged range the
address list shows A1. I want the the total address of the merged range
i.e. A1:A7 through VB. (Activecell.address shows A1 ) Can anyone help
me ?

Prasad Joshi


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Address of merged range VBA jlclyde Excel Discussion (Misc queries) 2 August 26th 09 03:14 PM
How can I sort an Excel Doc containing merged & non-merged cells? KellyH Excel Discussion (Misc queries) 11 June 10th 08 04:12 AM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


All times are GMT +1. The time now is 01:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"