![]() |
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! |
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! |
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! |
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! |
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! |
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! |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com