+ Reply to Thread
Results 1 to 4 of 4

I have a text of 1500 charachtars. How do I store it in a VBA variable

  1. #1
    Registered User
    Join Date
    07-13-2016
    Location
    Stockholm
    MS-Off Ver
    2013
    Posts
    27

    I have a text of 1500 charachtars. How do I store it in a VBA variable

    I have a text of 1500 charachtars. I want to store it in a VBA variable
    A "string" data type can contain up to 2 billion charahtars but I dont how to use it. I have a long text(1500 characters). But when defining my variable it gets cut of after first 255 charachters. How do I make my string contain 1500 charachtars?
    Here's my code

    sub test ()
    dim tmp as String
    tmp = " my long text string of roughly 1500 charachters "
    end sub


    I have also tried:

    sub test ()
    dim tmp as String * 1500
    tmp = " my long text string of roughly 1500 charachters "
    end sub


    Or maybe I should use another data type than string?

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: I have a text of 1500 charachtars. How do I store it in a VBA variable

    why not putting that variable into a cell and then make your string variable equal to that cell.

    Please Login or Register  to view this content.
    Teach me Excel VBA

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: I have a text of 1500 charachtars. How do I store it in a VBA variable

    What did you do to prove it gets cut off at 255 characters?

    This

    Please Login or Register  to view this content.
    produces a messagebox of at least 80 rows of 10 characters, that's 800 characters for a start.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: I have a text of 1500 charachtars. How do I store it in a VBA variable

    Hi Kbdb, when you say it is cut off after 255 characters, what exactly do you mean? A textbox would cut it off (I believe), but the string itself should actually contain the full 1500 characters.

    As a test, add a line of code that puts the string into a cell A1 for example, and then in another cell make put the formula "=Len(A1)" It should return 1500?
    Last edited by Arkadi; 12-13-2017 at 03:42 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

+ 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] Store text as variable between two words in Word from Excel VBA
    By javi-xls in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-26-2015, 06:03 PM
  2. How to store a value of a variable so that it can be used later ?
    By yoursamrit2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-27-2014, 03:29 PM
  3. [SOLVED] Store RGB(x, y, z) As Variable
    By ntitled in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2014, 01:05 PM
  4. [SOLVED] Store variable in worksheet and use that variable in VBA code
    By ExcelGal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2012, 08:20 AM
  5. text box input to store as a variable?
    By losmi8 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-06-2009, 01:25 PM
  6. store variable
    By keen learner in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2006, 10:30 AM
  7. How to store text to variable
    By jafery in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-29-2005, 05:18 AM

Tags for this Thread

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