+ Reply to Thread
Results 1 to 10 of 10

allowing for different string lengths in message box

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    allowing for different string lengths in message box

    The following code gives a warning message but the different string lengths of the registration numbers is offsetting longer values

    Please Login or Register  to view this content.
    I've tried quite a few methods, including the above function, but cant find the solution. Anyone any ideas?? Appreciated as its annoying
    Attached Images Attached Images
    Last edited by nigelog; 04-19-2018 at 04:05 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: allowing for different string lengths in message box

    Displaying text in column alignment is notoriously a pain. I would try creating a userform and displaying the data in a listbox with columns. The user will be able to click in it although it won't do anything. Alternatively it could be disabled but that would gray out the text.

    Here is a mock-up using the little bit of information you provided:
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: allowing for different string lengths in message box

    Thanks Jeff

    I've spent an ordinate mount of time stubbornly trying to sort but as there are only ever 6 or so I think I'll adapt your userform and listbox

    Ta

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,925

    Re: allowing for different string lengths in message box

    You may have to pad the input data. It looks like 9 spaces should do it.

    Please Login or Register  to view this content.
    Include this function in your module
    Please Login or Register  to view this content.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: allowing for different string lengths in message box

    I've made a small example file you can adapt to your situation.
    The code searches the longest string in column B and the spacing is related to that.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: allowing for different string lengths in message box

    @ dflak

    I got a syntax error at
    Please Login or Register  to view this content.
    @Bakerman2

    Did the job after adding "+2 after your code, I can adapt that. Many thanks
    Please Login or Register  to view this content.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: allowing for different string lengths in message box

    Glad to help. Thanks for rep+.

    PS
    Probably a typo by dflak but this should work
    Please Login or Register  to view this content.

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: allowing for different string lengths in message box

    Yep, that worked too..

    Please Login or Register  to view this content.

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: allowing for different string lengths in message box

    Just for information, you can reduce the PadString function to this
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  10. #10
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: allowing for different string lengths in message box

    Perfect Don

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Extract String After and Before Certain Characters of Variable Lengths
    By ex245 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-05-2017, 09:59 PM
  2. VBA to parse a text string containing three fields of different lengths
    By rupsidhu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2015, 09:01 PM
  3. Variable VBA Array Lengths, insert into cell as string
    By Speshul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2014, 04:26 PM
  4. [SOLVED] Formula to find a match with different string lengths
    By mcranda in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-09-2013, 04:34 PM
  5. Trim/parse from right within cell - string lengths different
    By oprpjm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-26-2013, 03:55 PM
  6. Replies: 3
    Last Post: 05-09-2012, 11:36 AM
  7. CONCATENATE Spacing Issue Due to String Lengths
    By ffmariners in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-17-2008, 02:32 PM

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