+ Reply to Thread
Results 1 to 2 of 2

Select cell with variable reference

  1. #1
    Registered User
    Join Date
    09-28-2004
    Posts
    6

    Select cell with variable reference

    I'm not able to get the following problem solved in Excel.

    I've written a macro. In this macro the value of cell C1 has to be copied to a cell in the worksheet. The value of the destination cell is variable and displayed in cell D1.

    so if the value of cell D1 = "AA10" then the value of C1 has to be copied in cell AA10

    if the value of cell D1 = "Q34" for instance, the value of cell C1 has to be copied to cell Q34.

    So the value of the destination cell is in D1 and can be almost every value of the worksheet because it's the result of a SEEK function.

    Can anyone help me figure this one out.

    Thanks!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Haan0054,

    The referencing you are doing isn't possible with Worksheet Formulas. You have to use VBA to construct a macro to achieve your result.

    Macro Code:

    Sub CopyIndirect(Destination_Address As String, Source_Address As String)
    With ActiveSheet
    IndirectDstAddx = .Range(Destination_Address).Value
    .Range(IndirectDstAddx).Value = .Range(Source_Address).Value
    End With
    End Sub


    Copy and Paste this code into a VBA Module in your Project. If you have any questions or need additional help, e-mail me [email protected].


    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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