Results 1 to 9 of 9

Thread: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Cambridge,MA
    Posts
    20

    Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    Can anyone tell me how to display more than 255 characters in a particular cell without having Excel convert the string to #VALUE!

    I'm trying to display comments submitted to a DB in each cell and the more verbose people are causing problems.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    You could probably format the cell as text. Then either enable word wrap or merge cell.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Cambridge,MA
    Posts
    20

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    It already is....but I think it might have to do with the version of Excel....I'm using 2003 and another person is using Office 2000 and is getting the problem.


    Do you know if this is version related and if there is a workaround?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    I can test it out on Excel 2000 for you to see what I can determine.
    I have it on our terminal server. Be back.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    I started with 255 "x"'s and copied into Excel XP, and then nearly doubled it in size. It did not change anything. It took up nearly 4 lines, but fit into the cell until I edited it.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    His systems are running Office 2000 and 2003 only, not Office 2002.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    Ok, think I got a possible cause and solution here:
    Cause: Entering text when the formula requires a number or a logical value, such as TRUE or FALSE. Microsoft Excel cannot translate the text into the correct data type.

    Solution: Make sure the formula or function is correct for the required operand or argument, and that the cells that are referenced by the formula contain valid values. For example, if cell A5 contains a number and cell A6 contains the text "Not available", the formula =A5+A6 will return the error #VALUE!. Use the SUM worksheet function in the formula as follows to add the two values (the SUM function ignores text):
    =SUM(A5:A6)


    Cause: Entering or editing an array formula, and then pressing ENTER.

    Solution: Select the cell or range of cells that contains the array formula, press F2 to edit the formula, and then press CTRL+SHIFT+ENTER.


    Cause: Entering a cell reference, a formula, or a function as an array constant.

    Solution: Make sure the array constant is not a cell reference, formula, or function. For more information about items that can be used as array constants, click .


    Cause: Supplying a range to an operator or a function that requires a single value, not a range.

    Solution: Change the range to a single value.
    Change the range to include either the same row or the same column that contains the formula.


    Cause: Using a matrix that is not valid in one of the matrix worksheet functions.

    Solution: Make sure the dimensions of the matrix are correct for the matrix arguments.


    Cause: Running a macro that enters a function that returns #VALUE!.

    Solution: Make sure the function is not using an incorrect argument.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Location
    Cambridge,MA
    Posts
    20

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    the offending code is the following:

    VB Code:
    1. ws.Range(Cells(i, 4), Cells(i, 4)).Value = VBA.CStr(rst!comments)

    where rst!comments is a field of type mediumtext in a mySQL database. rst is an ADODB.Recordset

    and the len of Cstr(rst!commments) is > 255.

    does this help

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy One - VBA Macro causes Excel to !VALUE# with more than 255 character string

    Maybe try using the explicit property instead of relying on the default. It could be that it is
    trying to place the object in the cell instead of the value.

    VB Code:
    1. ws.Range(Cells(i, 4), Cells(i, 4)).Value = VBA.CStr(rst.fields("comments").Value)
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width