Click here to Skip to main content
12,360,037 members (57,772 online)
Rate this:
Please Sign up or sign in to vote.
See more: MS-Excel VBA
I'm trying to adjust the cell height of a flexgrid according the the cell contents.

for example:

if I enter a string that is too long to fit in a cell , I would like to have the flexgrid adjust the cell height according to how many linesthat string would take.

bear in mind that i don't want to change the column width & I am using VBA not VB

I am using an excel.xlsm work book and working from the VBE (alt+F11) with a user form
the user form controls :
A Flexgrid,
A Text box with (multLine/enterkeybehavior/Wordwrap) properties set to =True,
A command button

the way I have set it up to work:
the user clicks on a cell in the flexgrid,
this will make the text box visible
user enters a text in the text box
user clicks the command button , it transfers the contents of the text box to the cell of the flexgrid)

could someone help shed some light on How do I add code to wrap the string in the flexgrid cell or provide a sample code .

any help is much appreciated.
Posted 20-Feb-13 0:50am
Updated 20-Feb-13 0:55am
CHill60 20-Feb-13 6:55am
I've amended the tags on your question from "VB6" so that the appropriate people will actually look at the question

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

To change width of column, try this:
MSFlexGrid1.ColWidth(index) = 1250

To add text to FlexGrid control:
1) increase the number of rows
Dim i As Integer
i = Flex1.Rows +1
Flex1.Rows = i
2) add text to first column
With Flex1
    .Row = i-1 'the last one
    .Col = 0 'first column
    .Text = TextBox1.Text
End With[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100