Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default If Statement: How to test if a cell is merged or not?

Hi all! I am looking to do something like this:

If mergecells=True
(then do one thing)
Else
(do something else)
Endif

But I cannot figure out how to get VB to work with my logic. Any ideas?

Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default If Statement: How to test if a cell is merged or not?

Dim ma As Range
Set ma = Range("A3").MergeArea
If ma.Address = "$A$3" Then
MsgBox "not merged"
Else
MsgBox "merged"
End If


--
HTH

Bob Phillips

"Dr. M" wrote in message
...
Hi all! I am looking to do something like this:

If mergecells=True
(then do one thing)
Else
(do something else)
Endif

But I cannot figure out how to get VB to work with my logic. Any ideas?

Thank you!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default If Statement: How to test if a cell is merged or not?

One way:

If Range("A1").MergeCells Then
'Do one thing
Else
'Do something else
End If

In article ,
"Dr. M" wrote:

Hi all! I am looking to do something like this:

If mergecells=True
(then do one thing)
Else
(do something else)
Endif

But I cannot figure out how to get VB to work with my logic. Any ideas?

Thank you!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default If Statement: How to test if a cell is merged or not?

Use something like

If Range("A1").MergeCells Then
Do this
Else
Do something else
End If

--
Cheers
Nigel



"Dr. M" wrote in message
...
Hi all! I am looking to do something like this:

If mergecells=True
(then do one thing)
Else
(do something else)
Endif

But I cannot figure out how to get VB to work with my logic. Any ideas?

Thank you!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default If Statement: How to test if a cell is merged or not?

Hi,
This code checks the activecell to see if it is merged.

Sub TestForMergedCell()
Dim rng As Range

Set rng = ActiveCell

If rng.MergeCells = True Then
MsgBox "Activecell is merged."
Else
MsgBox "Activecell is NOT merged."
End If

End Sub



"Dr. M" wrote:

Hi all! I am looking to do something like this:

If mergecells=True
(then do one thing)
Else
(do something else)
Endif

But I cannot figure out how to get VB to work with my logic. Any ideas?

Thank you!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default If Statement: How to test if a cell is merged or not?

Thanks to all! You guys are the greatest!
--
Dr. M


"bdr200" wrote:

Hi,
This code checks the activecell to see if it is merged.

Sub TestForMergedCell()
Dim rng As Range

Set rng = ActiveCell

If rng.MergeCells = True Then
MsgBox "Activecell is merged."
Else
MsgBox "Activecell is NOT merged."
End If

End Sub



"Dr. M" wrote:

Hi all! I am looking to do something like this:

If mergecells=True
(then do one thing)
Else
(do something else)
Endif

But I cannot figure out how to get VB to work with my logic. Any ideas?

Thank you!

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
=if() statement -- test for any text in cell Jim D.[_2_] Excel Discussion (Misc queries) 4 March 20th 10 05:25 PM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
Merged Cells in Worksheet, Test for [email protected] Excel Discussion (Misc queries) 2 September 28th 06 05:09 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
How can one test against merged cells in VB.NET? Joe Kickass Excel Programming 0 September 21st 04 10:39 PM


All times are GMT +1. The time now is 08:27 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"