Target.Address is a merged cell

JustinT

New Member
Joined
Jun 6, 2018
Messages
1
Hi,

I am struggling with the VBA code below. The code works fine until I delete the contents of the target cell, this does not have the desired effect of hiding the row below. I believe this is due to the target cell B315 being merged with B316. Any ideas how I can rectify this? Thanks, Justin

PS I'm a complete novice of VBA :)


If Target.Address = "$B$315" Then
If Target.Value = "Free text (enter text below)" Then
Range("a316").EntireRow.Hidden = False
Else
Range("a316").EntireRow.Hidden = True
End If
End If
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the Board!

It is a known fact that merged cells wreak all kinds of havoc with things like sorting and VBA. They cause much more problems than they solve, and it is highly recommend that you avoid using them, if at all possible. Most serious programmers avoid using them at all costs.

If you were merging across single rows, there is a "Center Across Selection" formatting option that gives you the same visual effect, without all the issues (see here: https://www.atlaspm.com/toms-tutori...er-across-selection-instead-of-merging-cells/). Unfortunately, there really isn't a good alternative for replacing merged rows within a single column. Depending on why the reason for the merged cells in the first place, I might try to consider something like increasing the row height.
 
Upvote 0

Forum statistics

Threads
1,214,548
Messages
6,120,146
Members
448,948
Latest member
spamiki

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