Conditional Format

kop442000

Board Regular
Joined
Jul 1, 2004
Messages
179
Hi guys

Is it possibl to merge/unmerge cells as part of a conditional format? Or is it something I would have to do with a macro or something like that?

Thanks for any replies,
Kop.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You cannot do this via conditional formatting, however, here is an example of some event code which will merge a cell with the cell to its right if you enter the value 10 in it:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value = 10 Then
    Range(Target.Address & ":" & Target.Offset(0, 1).Address).MergeCells = True
End If
End Sub
 
Upvote 0
ok well I think I can work with that code to get something near what I want..

Could you just give me the same example as above, but merging if I was entering "10" in the cell D7 rather that in the target cell.

thank you!
 
Upvote 0
ok well I think I can work with that code to get something near what I want..

Could you just give me the same example as above, but merging say cell G3 if I was entering "10" in the cell D7?
thank you!
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$7" Then
    If Target.Value = 10 Then
        Range(Target.Address & ":" & Target.Offset(0, 1).Address).MergeCells = True
    End If
End If
End Sub
 
Upvote 0
but that still merges D7 right?

I need cell G5 to merge if D7 gets "10" typed in it... could you amend the code for that please?

Thank you,
kop.
 
Upvote 0
kop


How can you merge 1 cell?:eek:
 
Upvote 0
Because Lewiy originally talked about his code that "will merge a cell with the cell to its right".

So I was just refering to the cell to be merged to it's right.

My actual spreadsheet will require a few different merges but I just want to get a good idea of the code I need.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,377
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top