+ Reply to Thread
Results 1 to 5 of 5

Pasting the locations of selected cells

  1. #1
    Registered User
    Join Date
    06-01-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Pasting the locations of selected cells

    Hi all,

    I have some code that selects several cells. Of these specific selected cells, I need to paste locations onto another sheet. For example, if cells A42, B27, and C3 on Sheet1 are selected, on Sheet2 I would like to paste Sheet1!$A$42, Sheet1!$B$27, Sheet1!$C$3 into cells A1, A2, and A3 respectively. The point is that I would like a list of names of the selected cells. I can find the cells' locations via .Parent.Name and .Address, I think, but the pasting part has me confused.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Pasting the locations of selected cells

    Does this help?

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    06-01-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Pasting the locations of selected cells

    I was able to manipulate my code to basically just find the addresses, etc. and print them on the second sheet instead of ever selecting in the first place. (Was more confusing than it should have been.)

    But your code works great - thanks!
    I am not too familiar with arrays. Could you explain the significance of the comma in the split function? I see that if I omit the comma, the cell addresses all print in a list in one cell, whereas with the comma, they all show up in different cells. How does this work?

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Pasting the locations of selected cells

    The comma is the delimiter (you can specify others like "*",";",etc). The SPLIT function builds an array, starting at the beginning of the string and parses through a string until it encounters a delimiter, then it creates a new array row for the text to the right of the delimiter; So each occurrence of a delimiter creates a new array row.

  5. #5
    Registered User
    Join Date
    06-01-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Pasting the locations of selected cells

    Thank you! Good to know - split is a very helpful function.

+ 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