Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 64
Default Select Merge Areas

Sub FindMergedAreas()
Dim d, myCell As Range
Set d = Nothing
For Each myCell In ActiveSheet.UsedRange
If myCell.MergeCells Then
If d Is Nothing Then
Set d = myCell.MergeArea
MsgBox "First merged area is " & myCell.MergeArea.Address
Else
If Intersect(d, myCell.MergeArea) Is Nothing Then
MsgBox "Another merged area is " & myCell.MergeArea.Address
End If
Set d = Union(d, myCell.MergeArea)
End If
End If
Next myCell
End Sub

Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).
Thxs

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Select Merge Areas

Hi Al,



Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).


What problem are you experiencing with the macro?



It is rarely necessary, or desirable, to make selections.That said, to
select the merged areas, try inserting:



If Not d Is Nothing Then d.Select



after:



Next myCell




Incidentally:



Dim d, myCell As Range




does not do what you may think. This dims d as a variant and dims myCell as
a range object. Try instead:



Dim d as Range, myCell as range





---
Regards,
Norman



"al" wrote in message
ups.com...
Sub FindMergedAreas()
Dim d, myCell As Range
Set d = Nothing
For Each myCell In ActiveSheet.UsedRange
If myCell.MergeCells Then
If d Is Nothing Then
Set d = myCell.MergeArea
MsgBox "First merged area is " & myCell.MergeArea.Address
Else
If Intersect(d, myCell.MergeArea) Is Nothing Then
MsgBox "Another merged area is " & myCell.MergeArea.Address
End If
Set d = Union(d, myCell.MergeArea)
End If
End If
Next myCell
End Sub

Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).
Thxs



  #3   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 64
Default Select Merge Areas

Norman,
Thxs a lot for your prompt reply - actually am not experiencing any
problem with the macro - but I only want to improve it by selecting the
merged cells & unmerging them if necessary.
Cheers!!



Norman Jones wrote:
Hi Al,



Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).


What problem are you experiencing with the macro?



It is rarely necessary, or desirable, to make selections.That said, to
select the merged areas, try inserting:



If Not d Is Nothing Then d.Select



after:



Next myCell




Incidentally:



Dim d, myCell As Range




does not do what you may think. This dims d as a variant and dims myCell as
a range object. Try instead:



Dim d as Range, myCell as range





---
Regards,
Norman



"al" wrote in message
ups.com...
Sub FindMergedAreas()
Dim d, myCell As Range
Set d = Nothing
For Each myCell In ActiveSheet.UsedRange
If myCell.MergeCells Then
If d Is Nothing Then
Set d = myCell.MergeArea
MsgBox "First merged area is " & myCell.MergeArea.Address
Else
If Intersect(d, myCell.MergeArea) Is Nothing Then
MsgBox "Another merged area is " & myCell.MergeArea.Address
End If
Set d = Union(d, myCell.MergeArea)
End If
End If
Next myCell
End Sub

Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).
Thxs


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Select Merge Areas

If you're trying to unmerge all the cells, you could just do:

ActiveSheet.UsedRange.Cells.MergeCells = False



al wrote:

Norman,
Thxs a lot for your prompt reply - actually am not experiencing any
problem with the macro - but I only want to improve it by selecting the
merged cells & unmerging them if necessary.
Cheers!!

Norman Jones wrote:
Hi Al,



Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).


What problem are you experiencing with the macro?



It is rarely necessary, or desirable, to make selections.That said, to
select the merged areas, try inserting:



If Not d Is Nothing Then d.Select



after:



Next myCell




Incidentally:



Dim d, myCell As Range




does not do what you may think. This dims d as a variant and dims myCell as
a range object. Try instead:



Dim d as Range, myCell as range





---
Regards,
Norman



"al" wrote in message
ups.com...
Sub FindMergedAreas()
Dim d, myCell As Range
Set d = Nothing
For Each myCell In ActiveSheet.UsedRange
If myCell.MergeCells Then
If d Is Nothing Then
Set d = myCell.MergeArea
MsgBox "First merged area is " & myCell.MergeArea.Address
Else
If Intersect(d, myCell.MergeArea) Is Nothing Then
MsgBox "Another merged area is " & myCell.MergeArea.Address
End If
Set d = Union(d, myCell.MergeArea)
End If
End If
Next myCell
End Sub

Can anyone give me an alternative macro to the one above which would
select all merged areas of a sheet (instead of finding).
Thxs


--

Dave Peterson
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
How to select multiple areas with keyboard only Rotaluclac Excel Discussion (Misc queries) 2 June 6th 08 10:07 PM
Merge Excel data into specific form areas in a Word Doc duugg Excel Discussion (Misc queries) 1 April 21st 06 08:25 PM
How to merge all selected areas into one area iev Excel Programming 5 August 30th 05 03:47 PM
Select all pivot table areas/ranges on the active sheet problem DataFreakFromUtah Excel Programming 3 October 27th 04 04:57 PM
Code to select print out areas Jonsson Excel Programming 1 February 27th 04 02:52 PM


All times are GMT +1. The time now is 06:00 PM.

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

About Us

"It's about Microsoft Excel"