+ Reply to Thread
Results 1 to 14 of 14

userform listbox columnheads

  1. #1
    borg
    Guest

    userform listbox columnheads

    Hi,

    I used rowsource to set the data into a listbox and then set the columnheads
    to true hoping that the first row of the data would be fill into the header.
    But no such luck. Here is what I've tried:

    with userform1
    .listbox1.rowsource="A1:E25"
    .columnheads=true
    end with

    Is there a way to make the column headers be the data in cells "A1:E1"?

    Thanks.


  2. #2
    Norman Jones
    Guest

    Re: userform listbox columnheads

    Hi Borg,

    Try:
    '=============>>
    Private Sub UserForm_Activate()
    With Me.ListBox1
    .RowSource = "A2:E25"
    .ColumnHeads = True
    .ColumnCount = 4
    End With
    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "borg" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I used rowsource to set the data into a listbox and then set the
    > columnheads
    > to true hoping that the first row of the data would be fill into the
    > header.
    > But no such luck. Here is what I've tried:
    >
    > with userform1
    > .listbox1.rowsource="A1:E25"
    > .columnheads=true
    > end with
    >
    > Is there a way to make the column headers be the data in cells "A1:E1"?
    >
    > Thanks.
    >




  3. #3
    Helmut Weber
    Guest

    Re: userform listbox columnheads

    Hi Borg

    quote from Joanthan West, Word MVP:

    >There's a bug in VBA, and the ColumnHeads property doesn't work right.
    >You're supposed to be able to fill the individual column headings of a
    >listbox or combobox with text, but you can't


    --
    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Win XP, Office 2003
    "red.sys" & Chr$(64) & "t-online.de"


  4. #4
    Norman Jones
    Guest

    Re: userform listbox columnheads

    Hi Helmut,

    > quote from Joanthan West, Word MVP:


    >>There's a bug in VBA, and the ColumnHeads property doesn't work right.
    >>You're supposed to be able to fill the individual column headings of a
    >>listbox or combobox with text, but you can't


    In my experience, column headings work providing that the listbox is filled
    using the RowSource property and that the first row assigned to the property
    is the row immediately below the desired headings.

    Whilst I am unaware of the broader context of the Joanthan West quote, I
    experience no problem in displaying the required column headings.


    ---
    Regards,
    Norman


    "Helmut Weber" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Borg
    >
    > quote from Joanthan West, Word MVP:
    >
    >>There's a bug in VBA, and the ColumnHeads property doesn't work right.
    >>You're supposed to be able to fill the individual column headings of a
    >>listbox or combobox with text, but you can't

    >
    > --
    > Greetings from Bavaria, Germany
    >
    > Helmut Weber, MVP WordVBA
    >
    > Win XP, Office 2003
    > "red.sys" & Chr$(64) & "t-online.de"
    >




  5. #5
    Helmut Weber
    Guest

    Re: userform listbox columnheads

    Hi Norman,

    you are right, indeed.

    Maybe forms react differently in Excel and Word,
    should have tested it. :-(.

    With Me.ListBox1
    .RowSource = "A1:A30"
    .ColumnHeads = True
    End With

    creates a columnhead "Column A".

    Any idea how to modify or retrieve it?

    Thx.

    --
    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Win XP, Office 2003
    "red.sys" & Chr$(64) & "t-online.de"






  6. #6
    Norman Jones
    Guest

    Re: userform listbox columnheads

    Hi Helmut,

    > creates a columnhead "Column A".


    > Any idea how to modify or retrieve it?


    Perhaps, something like:

    '=============>>
    Private Sub CommandButton1_Click()
    Dim rng As Range

    Set rng = Range(Me.ListBox1.RowSource)
    MsgBox rng(0, 1).Value
    rng(0, 1).Value = "New"
    MsgBox rng(0, 1).Value
    Me.ListBox1.RowSource = Me.ListBox1.RowSource

    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "Helmut Weber" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Norman,
    >
    > you are right, indeed.
    >
    > Maybe forms react differently in Excel and Word,
    > should have tested it. :-(.
    >
    > With Me.ListBox1
    > .RowSource = "A1:A30"
    > .ColumnHeads = True
    > End With
    >
    > creates a columnhead "Column A".
    >
    > Any idea how to modify or retrieve it?
    >
    > Thx.
    >
    > --
    > Greetings from Bavaria, Germany
    >
    > Helmut Weber, MVP WordVBA
    >
    > Win XP, Office 2003
    > "red.sys" & Chr$(64) & "t-online.de"
    >
    >
    >
    >
    >




  7. #7
    Helmut Weber
    Guest

    Re: userform listbox columnheads

    Hi Norman,

    hmm...

    seems to set the value of the first item in the list,
    but not the columnhead.

    --
    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Win XP, Office 2003
    "red.sys" & Chr$(64) & "t-online.de"

  8. #8
    Norman Jones
    Guest

    Re: userform listbox columnheads

    Hi Helmut,

    > hmm...
    >
    > seems to set the value of the first item in the list,
    > but not the columnhead.


    Conversely, the siggested code retrieves, changes and re-retrieves the
    column header for me.

    Should you wish, I can send you my test file.

    ---
    Regards,
    Norman



  9. #9
    Helmut Weber
    Guest

    Re: userform listbox columnheads

    Hi Norman,

    >Should you wish, I can send you my test file.


    please do,
    however hard I try,
    Excel seems to stay a mystery to me.

    --
    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Win XP, Office 2003
    "red.sys" & Chr$(64) & "t-online.de"

  10. #10
    Edwin Tam
    Guest

    Re: userform listbox columnheads

    Norman,

    May I have a look at your sample file also?

    Thanks!

    Regards,
    Edwin Tam
    [email protected]
    http://www.vonixx.com


    "Norman Jones" wrote:

    > Hi Helmut,
    >
    > > hmm...
    > >
    > > seems to set the value of the first item in the list,
    > > but not the columnhead.

    >
    > Conversely, the siggested code retrieves, changes and re-retrieves the
    > column header for me.
    >
    > Should you wish, I can send you my test file.
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >


  11. #11
    Tom Ogilvy
    Guest

    Re: userform listbox columnheads

    The code worked fine for me.

    --
    Regards,
    Tom Ogilvy


    "Helmut Weber" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Norman,
    >
    > hmm...
    >
    > seems to set the value of the first item in the list,
    > but not the columnhead.
    >
    > --
    > Greetings from Bavaria, Germany
    >
    > Helmut Weber, MVP WordVBA
    >
    > Win XP, Office 2003
    > "red.sys" & Chr$(64) & "t-online.de"




  12. #12
    Helmut Weber
    Guest

    Re: userform listbox columnheads

    Hi,

    thanks everybody.

    I see, the value from the first cell in the column
    becomes the columnheader! I phantasized of a way
    to have the columnheader independant of the values in the column.

    --
    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Win XP, Office 2003
    "red.sys" & Chr$(64) & "t-online.de"





  13. #13
    Tom Ogilvy
    Guest

    Re: userform listbox columnheads

    No, that is not supported.

    --
    Regards,
    Tom Ogilvy

    "Helmut Weber" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > thanks everybody.
    >
    > I see, the value from the first cell in the column
    > becomes the columnheader! I phantasized of a way
    > to have the columnheader independant of the values in the column.
    >
    > --
    > Greetings from Bavaria, Germany
    >
    > Helmut Weber, MVP WordVBA
    >
    > Win XP, Office 2003
    > "red.sys" & Chr$(64) & "t-online.de"
    >
    >
    >
    >




  14. #14
    Spike
    Guest

    Re: userform listbox columnheads

    Any Help?

    I have a listbox in a word form. i want the rowsource to reference my excel
    document. If i do this in excel VBA it works fine, but when i try it in word
    VBA it will not. The following are the two lines that work in excel but not
    word.

    wbUserFile.ActiveSheet.Cells(2, 2).Resize(5).Select
    lstGraphInfo.RowSource = MyExcel.Selection.Address(External:=True)

    thanks

    --
    Jeff "Spike" Zapinski



    "Norman Jones" wrote:

    > Hi Borg,
    >
    > Try:
    > '=============>>
    > Private Sub UserForm_Activate()
    > With Me.ListBox1
    > .RowSource = "A2:E25"
    > .ColumnHeads = True
    > .ColumnCount = 4
    > End With
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "borg" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I used rowsource to set the data into a listbox and then set the
    > > columnheads
    > > to true hoping that the first row of the data would be fill into the
    > > header.
    > > But no such luck. Here is what I've tried:
    > >
    > > with userform1
    > > .listbox1.rowsource="A1:E25"
    > > .columnheads=true
    > > end with
    > >
    > > Is there a way to make the column headers be the data in cells "A1:E1"?
    > >
    > > Thanks.
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1