• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

Excel: Hide extended content with VBA

Hello, i'm using selection.value to write value in a cell.
The problem is the value is very long so it display over the next cells

as you can see on attached. But its strange that CELL E2 which also fill with long content can keep the extended content hidden.

how to solve this problem ?

display.jpg
0
veematics
Asked:
veematics
2 Solutions
 
ragnarok89Commented:
Cell contents will overflow to the right if the cell on the right is blank. I can think of 3 fixes for this:

1. Right click cell, > Alignment > Wrap text
2. add a "space" to each of your blank cells
3. use merged cells to the right. text never flows over to a merged cell

Al
0
 
SafetyFishCommented:
Excel only hides the extended text in a cell when the adjacent cell has a value in it. See in F2, there is a value written. Write some values in F3, F4, and F5 and see if that doesn't hide the extended content. Otherwise, you could also simply make the column wider. That  may or may not be practical for you, though.
0
 
veematicsAuthor Commented:
@ragnarok89 , Right click cell, > Alignment > Wrap text <- can we do that with scripts (vba)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SafetyFishCommented:
Yes. I think it goes:

RangeObject.Font.WrapText = True [or False]
0
 
SafetyFishCommented:
My bad, no need to put Font in there. It seems to work best as simply:

RangeObject.WrapText = True
0
 
slycoderCommented:
This is just a cheating way of doing it -

You can hide that column, then insert a column that contains the summary of the hidden column.

1) Insert new column F (note this may change your macro references)
2) Starting at row 2 use the formula =LEFT(E2,10) change the #10 as needed
3) copy down as needed
4) hide column E

Hope this helps

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now