+ Reply to Thread
Results 1 to 4 of 4

Using a VAR with a Goto

  1. #1
    Registered User
    Join Date
    01-21-2010
    Location
    Milano
    MS-Off Ver
    Excel 2003
    Posts
    9

    Using a VAR with a Goto

    Hi all,

    I need to copy a selection into a column but the cell where i need to do it can change.

    I managed to indicate the correct destination in a cell named "loc" but I don't know how to tell my macro to use this value.

    Here is the code I m trying to work with:

    Please Login or Register  to view this content.

    Thanks for any clue you can give me
    Last edited by DonkeyOte; 02-12-2010 at 05:27 AM. Reason: code tags

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Using a VAR with a Goto

    Welcome to the Board.

    Please use CODE tags around VBA at all times... on this occasion (first post) I've modified for you.

    It's not clear immediately what you want to do but you could perhaps replace your code with:

    Please Login or Register  to view this content.

    However your use of GoTo implies you want to navigate to your named range - is that the case ?

  3. #3
    Registered User
    Join Date
    01-21-2010
    Location
    Milano
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Using a VAR with a Goto

    Thanks DonkeyOte for your quick reply, let me try to explain better what i m trying to do...

    Dim loc As Range

    ' I m trying to give to the var loc the cell reference present in J1
    loc = Worksheets("Resultat").Range("J1").Value

    ' Selection of the range I want to copy
    Range("D2:E5").Select
    Selection.Copy

    ' Here I want the cursor to go to the cell reference present in J1(loc)
    Application.Goto Reference:=loc

    ' And paste the selection

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Using a VAR with a Goto

    As mentioned in my prior post...

    Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing.
    Your post does not comply with Rule 3 of our Forum RULES.
    Highlight your code and click the # at the top of your post window (click GoAdvanced if you can not see the # icon)

    For more information about these and other tags, found here

+ 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