+ Reply to Thread
Results 1 to 13 of 13

Make excel paste at certain row

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235

    Make excel paste at certain row

    Hi all, Can excel paste details from one worksheet to a specific row within another worksheet ( row number is the result of using the match command ) so it can be used to modify a particular row?, if so, can anybody help with a VBA example please?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What are you matching.

    Use either the VBA Find method or Match to get the Row number
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235
    Hi royUK, I have used the match & row() to find the row number of what I am looking for but want to create another worksheet that looks up the details on that row found, and if I add some details want some VBA to tell excel to paste the information at that row number instead of having to look for the details on a specific row manually.

  4. #4
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235

    Paste into specific row

    Im trying to paste data from sheet1 into sheet2 based on a specific row number that I get as a result of using the match command. How can I make excel paste automatically into the specific row in sheet2.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    A lot of this will need to be changed to meet your situation, but the syntax for the destination will put whatever is copied to the matching range starting at Sheet2, row rowNumber, column 1.
    Dim rowNumber as Long, matchRange as Range
    rowNumber=Application.Match("x",matchRange,0)
    Sheets("Sheet1").Range("a2:e2").Copy Destination:=Sheets("Sheet2").Cells(rowNumber,1)

  6. #6
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235

    Thumbs up

    Thank you for your help, will keep you informed.

  7. #7
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235
    Hi there, I seem to have difficulty is using your code, It is giving a compile error and must admit im still new to VBA. In sheet 1, is where I search from the daya in sheet 2 using match - so this gives me say row 20.

    Now I have the details from row 20 displayed in sheet 1, I modify that info and have a button I can link to your VBA to make it copy from sheet 1 back to sheet 2 row 20.

    Any help is much appreciated.

  8. #8
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235

    VBA to paste at given row

    Im trying to modify cells within an existing database and am using the match & index commands to find and display results from a specific row, say row 30, how could VBA be used to copy some cells from one sheet to the database sheet at the given row number of 30 or which ever row number the match command comes up with?

  9. #9
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Set a variable to your found row number

    myrow = 30
    I've just set it to 30, but you would use whatever process to do that.

    You can then use the cells command to determine the output cell
    cells(myrow,1).value = range("A1").value
    In this case I have set the value in A30 to be the same as A1.

    Bit hard to be more specific unless you give more detail on your structure, what you want to take from where, and where you want to put it.

    rylo

  10. #10
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235
    Hi there, I have attached a very small zip file that has a working version of what I am trying to do - it explains where I am trying to copy to and from.

    Although I am OK at worksheet formula's, VBA is still mind boggling and need all the help I can get, so would appreciate as much help you can provide me.

    Is it possible to write within the macro lines that I can edit to make the places it pastes to different, i.e the example refers to Sheet2 but my actual database may be DBase1 or DBase2 etc.

    Thanks
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    235
    Sorry, this version of match & index works - sorry if anybody downloaded previous version.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try this. Your row isn't really the row of the item, but the position in the defined range. I've added 3 to the result based on your layout.

    rylo
    Attached Files Attached Files

+ 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