Results 1 to 6 of 6

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

Threaded View

  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.
    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        Dim myData As Range
        Set myData = Range("A1")
        myData.Copy
        Range("A5").Select
        ActiveSheet.Paste
    End Sub
    I have tried replacing the second line in my code with the following but a Run-time Error '424' is the result.
    Set myData = Range("A1").Text
    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.

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