+ Reply to Thread
Results 1 to 6 of 6

How to take cell with custom format and assign to variable as text (as appears in cell)

  1. #1
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    How to take cell with custom format and assign to variable as text (as appears in cell)

    Hello,

    I have a cell 'A1' with a custom format. The value typed in the cell is '58' but the custom format forces it to appear as 'R00058'.

    How would you assign 'R00058' to a variable which will be later used for other functions?

    Using the following code as a test I am assigning Range("A1") to a variable and pasting it in cell 'A5'. This does not work as desired because all it's doing is copying the cell with the format applied.
    Please Login or Register  to view this content.
    I have tried replacing the second line in my code with the following but a Run-time Error '424' is the result.
    Please Login or Register  to view this content.
    Also, when is it necessary to use 'Set'? I have also searched and found limited use of 'Let'.

    Getting rid of 'Set' in that line of code results in an Run-time error '91': Object variable or With block variable not set.


    Thanks for any help.

    TV
    Last edited by tv69; 01-07-2014 at 11:45 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: How to take cell with custom format and assign to variable as text (as appears in cell

    I think what you want is:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: How to take cell with custom format and assign to variable as text (as appears in cell

    yudlugar,

    That does work just fine. How about assigning Range("A1").Text to my variable 'myData'? How might that work?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: How to take cell with custom format and assign to variable as text (as appears in cell

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to take cell with custom format and assign to variable as text (as appears in cell

    Not exactly sure what you want to do but this would put the value from the cell as it's formatted into the variable.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Here
    MS-Off Ver
    Excel 2010
    Posts
    119

    Re: How to take cell with custom format and assign to variable as text (as appears in cell

    Thank you both for your input. I was over complicating things. It all works out now.

+ 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. Custom Format to Align Text in a Cell
    By bhenlee in forum Excel General
    Replies: 1
    Last Post: 08-23-2013, 08:21 AM
  2. Format A Cell Background Only Where Text Appears
    By nathanB in forum Excel General
    Replies: 3
    Last Post: 11-22-2012, 07:13 AM
  3. [SOLVED] Find partial text in cell and assign variable a value if found
    By lday75 in forum Excel General
    Replies: 4
    Last Post: 07-26-2012, 01:36 PM
  4. Replies: 2
    Last Post: 07-24-2012, 11:47 AM
  5. Format Cell Data so text appears in neat format?
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2010, 09:18 AM

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