Adjust string ouptut in cell

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Adjust string ouptut in cell

Post by YasserKhalil »

Hello everyone
I have weird case.. maybe as for me

I have a code that puts some data in cell. The data appears like that
01.png
And after I double click into the cell I got
02.png
How can I get the output as in the second case directly without having to double-click the cell?
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Adjust string ouptut in cell

Post by HansV »

I see this when I open the workbook:
S3205.png
The following line will adjust the row height:

Code: Select all

    Range("A2").EntireRow.AutoFit
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Adjust string ouptut in cell

Post by YasserKhalil »

The row height is already fit. and I tested the line of AutoFit but the same output for me.
Any other ideas?
Is there a code that double clicks the cell ..!!!!!!!!?

User avatar
StuartR
Administrator
Posts: 12605
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Adjust string ouptut in cell

Post by StuartR »

I see the same as Hans. I just open the workbook and it looks like his screenshot. If I double click the cell there is no noticable change in appearance.
StuartR


YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Adjust string ouptut in cell

Post by YasserKhalil »

Thanks a lot. Maybe this bug in Office 365 !! It is weird for me too

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Adjust string ouptut in cell

Post by HansV »

It's strange - I'm using Excel 2019, which isn't very different from Excel in Office 365...
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Adjust string ouptut in cell

Post by YasserKhalil »

But the problem is gone when I double click in the cell. Is there a workaround to double click the cell?

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Adjust string ouptut in cell

Post by HansV »

You could try

SendKeys "{F2}{Enter}"

But that doesn't work for me.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Adjust string ouptut in cell

Post by YasserKhalil »

This works for me. Thanks a lot
But if there are any other workarounds except using SendKeys, it will be better.

User avatar
HansV
Administrator
Posts: 78483
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Adjust string ouptut in cell

Post by HansV »

F2 enters edit mode. This is not available in VBA in a normal way - VBA doesn't work in cell edit mode. So SendKeys is the only workaround.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Adjust string ouptut in cell

Post by YasserKhalil »

I thought of using Text To Columns method and I tried several tries but with no use.