+ Reply to Thread
Results 1 to 10 of 10

Scroll textbox if the adjacent is scrolled

  1. #1
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Scroll textbox if the adjacent is scrolled

    Hi forum, I have another questions about textboxes.

    I'm trying to create a userform to insert data in a worksheet.
    The user has to choose a macro-category and add multiple items (read lines of data) for such categorized list, I store the data in multiline textboxes to allow the user to complete the data entry and still view all the lines entered.
    Since the lines for each data entry may be more than I can show in the textbox window I opted to set the scrollbars to vertical to allow the user to scroll through the lines.
    The functioning is fine, but I would want the adjacent textbox to scroll as well when the user trigger one of them..is this possible? Would it be possible even if I had more than one textbox to update? Listboxes best suit this achievement?

    I attach a dummy worksheet which was updated with the previous thread resolved by RoyUK and another increment sub I created.

    thanks again for your help
    P.
    Attached Files Attached Files
    Last edited by fredpox; 04-27-2010 at 04:41 PM. Reason: SOLVED

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Scroll textbox if the adjacent is scrolled

    If you use a listbox you can make it multi-column which (of course) all scroll together. Therefore doing away with multiple controls.

    Does this answer your need?


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Scroll textbox if the adjacent is scrolled

    Hi Tony, and sorry for the terrible delay..I've been off for the last few days..
    yes, I didn't think at first that listboxes would have fit my needs.
    I just need to realize how to store multiple values one per column.
    Consider I have 4 columns in my ListBox.

    I wrote something like this but I get a compiling error, value separator expected.
    Please Login or Register  to view this content.
    If I put a comma (,) as value separator debug tells me an equal sign (=) is expected.

    I tried to handle all the data as a single string but it's not the way it's supposed to work a multicolumn listbox right?
    Please Login or Register  to view this content.

    thanks again for your help
    P.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Scroll textbox if the adjacent is scrolled

    Try this way
    Attached Files Attached Files
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Scroll textbox if the adjacent is scrolled

    Updated to show how to use the Listbox selections
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Scroll textbox if the adjacent is scrolled

    Hi RoyUK,
    thanks for your support.
    Your code works fine but when I try to implement it for my needs I still have something to tweak.
    I set the Userform Initialize Sub like this:
    Please Login or Register  to view this content.
    And the InsertData Sub like this:
    Please Login or Register  to view this content.
    Even though I set the columns to 5 I can see only 4 data per listbox row.
    At first I set the first .Listbox.List(ref - 1,1) = ListBox.ListCount + 1 but then I noticed the Sub already add the line num with the ref variable in .ListBox.AddItem

    In brief, what I get now is that I can't see displayed the amount calculated in the last ListBox.List row.
    Furthermore the 1st column of the ListBox is way larger than I want it to be, so the others..somehow it happens the .ColumnWidths property is not read correctly, isn't it?

    Last thing: is there a way to temporarily 'disable' the Subs invoked with Change on Hours and HourPay when I clear all the textboxes at the end of the InsertData_Click Sub? How can I change those Subs?

    thanks again for your help,
    P.
    Attached Files Attached Files
    Last edited by fredpox; 04-25-2010 at 03:46 PM. Reason: file added

  7. #7
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Scroll textbox if the adjacent is scrolled

    Hi RoyUK,
    it's ok, I realized that I had to start the .ListBox.List(ref - 1,1) = Description.Value and so on and all the values I want are displayed (last one is .ListBox.List(ref-1,4) instead of ref-1,5).
    Still remains the problem of the width which is too large..

    thanks again
    P.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Scroll textbox if the adjacent is scrolled

    I've amended your code and set the width manually using the ColumnWidth Property,they need tweaking a little
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Scroll textbox if the adjacent is scrolled

    Thanks a lot RoyUK,
    I'll give it a look asap.
    Have a nice day!
    P.

  10. #10
    Registered User
    Join Date
    02-21-2010
    Location
    Italy
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: Scroll textbox if the adjacent is scrolled

    Hi RoyUK,
    your code is great, you tweaked it fine enough, thanks! :-)

    bye
    P.

+ 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