VBA to show cell blank if cell value is same as cell above

Merlot85

New Member
Joined
May 12, 2017
Messages
2
Good Day,

I am very new to coding and would like to ask for assistance in writing a code to:

Show the cell as blank if the cell above contains the same value. I would like to do this for a range of cells. Also the cell values may differ eg.

Bahamas
Bahamas
Bahamas
England
England
Unites States
United States
United States

Would anyone also be able to guide me as to where I can begin if I would like to learn to write codes on my own?

Thanks in advance
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Welcome to the Board!

I think the easiest way to do this is to use Conditional Formatting. That won't actually delete those values, but rather "hide" them from view.
Let's say that your values are in A1-A8.
Then, highlight cells A2:A8, and enter the following Conditional Formatting Formula:
=A2=A1
Then choose the white font option.

So, if the value in once cell is the same as the value above it, the font color of that cell will be changed to the same color as the background, making that value not visible.
 
Upvote 0
sounds like you would just setup conditional formatting. Under the home tab on the ribbon you can find it. The idea is you would apply it to whatever range of cells you like and you create a formula that results in true or false and you create the formatting for if it is true. So your formula would compare the current cell to the one above it. It is a little tricky how you write the formula as it works for the first cell and as if you dragged the formula for others (huh? lol)

Look at my rule for E6:E12 (ignore the other stuff) I assure you the value 5 and 4 are now hidden in E8 and E12. For formatting I used a custom number format where I just put two quotes ""

n6lbMtd.png
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,688
Members
449,117
Latest member
Aaagu

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