Results 1 to 4 of 4

Convert a string to cell reference in VBA

Threaded View

Iswarya Convert a string to cell... 08-16-2010, 05:21 AM
Andy Pope Re: Convert a string to cell... 08-16-2010, 05:30 AM
nnram123 Re: Convert a string to cell... 08-16-2010, 11:29 PM
royUK Re: Convert a string to cell... 08-17-2010, 02:34 AM
  1. #1
    Registered User
    Join Date
    04-16-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Convert a string to cell reference in VBA

    I have a piece of VBA code like this

    Cell A1 has the value G4.

    varName = Range("A1").Value
    Range("C2").Formula = "='Sheet2'!" & varName

    What I'm trying to do is write this formula Sheet2!G4 within cell C2. Essentially, I guess I'm trying to achieve an indirect.

    But when i run it, C2's formula appears like this:
    'Sheet2'!'G4'

    It also shows an error. I'm assuming this is because of G4 appearing in quotes when the formula is written in the cell. How can I remove this? How can I change the string varName to a range type? Or is there any other workaround for this?


    ---------Cross-posted in Mr Excel here.---------------
    Last edited by romperstomper; 08-16-2010 at 05:43 AM. Reason: add link

Thread Information

Users Browsing this Thread

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

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