vb this

Hello All,
I need a VBA code for this – as I type in stuff in the cells, it adjusts the height to accommodate all that text.
For example – if I type in “word” the cell height adjusts to fit that in, if I type in “dsfsdfsdfsdfsdfsdfsdfsdf”, the cell height increases to fit in all that junk.
Thank you
RayneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
This is not VBScript, I know.   I'm posting this in case it helps bypass the need for any scripting on your part...

You can set the cell to resize based on what's in it.  Format -> Alignment -> "Wrap text" will do essentially what you want.
0
unknown_routineCommented:
Here is the VBA code:



Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
 
 ActiveCell.EntireColumn.AutoFit
 
 
End Sub

For this to work user should press Enter after he types something.



If you want to Wrap(height will be auto adjusted) use this:


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
 
ActiveCell.EntireColumn.WrapText
 
 
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
[ fanpages ]IT Services ConsultantCommented:
Hi,

I need a VBA code for this – as I type in stuff in the cells, it adjusts the height to accommodate all that text.

Just a comment on what has been provided so far; the adjustment of the cell dimensions will only take affect when the entry is confirmed ([Return]/[Enter] key, or selecting another cell, for instance).

The dimensions of the cell will not change whilst a value is being entered.  The cell dimensions will not be as dynamic as I think you were looking for.

You could, however, use a textbox control on top of a cell & capture the individual key presses of the characters being entered so that the textbox can change dimensions as you type.

Once the entry is confirmed, the cell can then change dimensions to match.

BFN,

fp.
0
RayneAuthor Commented:
sorry for the delayed reply, I was out drinking :(

Unknown_Routine - you rock my friend!! your routine that was (unknown) to me, did the magic i was looking for. Thank you a million
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.