Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Merged Cells Question

if your Range.EntireRow contains merged cells how can you test for that and
if true, unmerge the cells?

i have something like this but not working.

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Merged Cells Question

I'm not sure if there is a way to test that a row has merged cells. If you
want to unmerge cells in a range just use one of these procedures.

Sub UnMergeRange()

' unmerge all cells in the used range
Sheets("Sheet1").UsedRange.UnMerge

End Sub

or

Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40".UnMerge

End Sub

Is this what you wanted? Hope this helps.
--
Cheers,
Ryan


"Jim" wrote:

if your Range.EntireRow contains merged cells how can you test for that and
if true, unmerge the cells?

i have something like this but not working.

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Merged Cells Question

Correction!
Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40").UnMerge

End Sub

--
Cheers,
Ryan


"RyanH" wrote:

I'm not sure if there is a way to test that a row has merged cells. If you
want to unmerge cells in a range just use one of these procedures.

Sub UnMergeRange()

' unmerge all cells in the used range
Sheets("Sheet1").UsedRange.UnMerge

End Sub

or

Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40".UnMerge

End Sub

Is this what you wanted? Hope this helps.
--
Cheers,
Ryan


"Jim" wrote:

if your Range.EntireRow contains merged cells how can you test for that and
if true, unmerge the cells?

i have something like this but not working.

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function

  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Merged Cells Question

I guess the rngFound is kinda confusing what i actually need to do. I have a
program that looks in column "I" for a value and if the value matches what
its looking for it copies row-paste to sheet(2)-Deletes Entire row (in
sheet(1)). I am getting an error that says "Cannot changed part of a merged
cell" so im guess im saying i need to unmerge just 1 row at a time if it has
any part of it merged with other cells

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function

"RyanH" wrote:

Correction!
Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40").UnMerge

End Sub

--
Cheers,
Ryan


"RyanH" wrote:

I'm not sure if there is a way to test that a row has merged cells. If you
want to unmerge cells in a range just use one of these procedures.

Sub UnMergeRange()

' unmerge all cells in the used range
Sheets("Sheet1").UsedRange.UnMerge

End Sub

or

Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40".UnMerge

End Sub

Is this what you wanted? Hope this helps.
--
Cheers,
Ryan


"Jim" wrote:

if your Range.EntireRow contains merged cells how can you test for that and
if true, unmerge the cells?

i have something like this but not working.

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Merged Cells Question

In the future I would recommend not to merge cells becuase as you can see it
is a thorn in the side when it comes to coding. I would just use this line
before you copy the entirerow. I'm will assume you are using a For...Loop,
thus the row address is i. If not, replace i with your row number. Post
your code, it would help.

Rows(i).UnMerge

Hope this helps! If so, click "Yes"
--
Cheers,
Ryan


"Jim" wrote:

I guess the rngFound is kinda confusing what i actually need to do. I have a
program that looks in column "I" for a value and if the value matches what
its looking for it copies row-paste to sheet(2)-Deletes Entire row (in
sheet(1)). I am getting an error that says "Cannot changed part of a merged
cell" so im guess im saying i need to unmerge just 1 row at a time if it has
any part of it merged with other cells

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function

"RyanH" wrote:

Correction!
Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40").UnMerge

End Sub

--
Cheers,
Ryan


"RyanH" wrote:

I'm not sure if there is a way to test that a row has merged cells. If you
want to unmerge cells in a range just use one of these procedures.

Sub UnMergeRange()

' unmerge all cells in the used range
Sheets("Sheet1").UsedRange.UnMerge

End Sub

or

Sub UnMergeRange()

' unmerge all cells in the range you specified
Sheets("Sheet1").Range("A1:P40".UnMerge

End Sub

Is this what you wanted? Hope this helps.
--
Cheers,
Ryan


"Jim" wrote:

if your Range.EntireRow contains merged cells how can you test for that and
if true, unmerge the cells?

i have something like this but not working.

Function MergeSub( )
Dim rng as Range
Set rngFound = Range("A1:P40")

If rng.MergeCells = True Then
rngFound.EntireRow.MergeCells = False
End If
End Function

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
Copy paste non merged to merged cells [email protected] Excel Worksheet Functions 1 February 5th 09 05:25 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 03:13 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"