+ Reply to Thread
Results 1 to 15 of 15

VBA Code to copy cell range and paste to certain sheet

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    VBA Code to copy cell range and paste to certain sheet

    hello all!

    this is my first post here, i`ve been dabbling in VBA coding for simple and medium macros, but right now i really need some help. here`s what i`m trying to do:

    find a range of cells in some sheet, based on the string in column "B" then, i want all the values in the range E-P (in the "infosheet" tab) to be copied to a summary sheet in a range C-M (sheet "summary sheet 2" in the example). i know, it sounds vague, but i will attach an example workbook, to clarify things.

    once i get this down, i am sure i can tweak it to do the same for some other totals i need in yet another sheet ("summary sheet 1")

    please bare in mind that the range of the source table (sheet "infosheet" in the example) is dynamic (might have 70 rows this month, 60 or 80 next month).

    any kind of helo will be greatly appreciated.

    cheers!!

    examplesheet.xlsx

  2. #2
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    i was thinking of something along the lines of :

    Please Login or Register  to view this content.
    of course, i need to do this for 8 other sheets, but once i get pointed in the right direction, i can get that to loop for all sheets.
    Last edited by goguneon; 08-29-2013 at 05:26 AM.

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: VBA Code to copy cell range and paste to certain sheet

    Do you need macro or formula .

  4. #4
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    Quote Originally Posted by kvsrinivasamurthy View Post
    Do you need macro or formula .
    hi, i would like this as a macro, but if you can provide a formula which i can also use and integrate into a macro, that would also work.

    right now i`m looking to save some time (been trying to get this to work for about 4 days now).

    thanks!!

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Code to copy cell range and paste to certain sheet

    Maybe:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    will test this and provide feedback momentarily.

    cheers!

  7. #7
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    tried it, tweaked it for my own special needs. after that it did what it was supposed to do, but i need the "paste" in the "summary sheet 2" to be special->values.

    also, could you include some reference there as to the sheet it's extracting the data from? i will need to take this through 8 other sheets, and i don't want the same data pasted in the entire table.

    something like:

    Please Login or Register  to view this content.
    that would be really helpful.

    for the most part i prefer to stay away from automatic copying, but going back and forth between 9 sheets + copy/paste it takes a lot of time that can be saved by doing this.

    thank you!!

  8. #8
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    the above code pastes the copied contents with the background formatting, and i don't need that. moreover, it deletes the row below, like in the picture. all i need is for it to get the values and paste them in there.

    1.JPG

    cheers!

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Code to copy cell range and paste to certain sheet

    Maybe:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    Mr.Davis, thank you very much for taking the time to do this.

    unfortunately, for some strange reason, the copying is done, it copies the exact thing that i need, but, when it pastes the info to the target area, all it pastes is 0(zero), for the entire range. the info that is copied is part of a subtotal formula, so, it should work, when pasting only the values.

    i have manually pasted the info in the clipboard and it is accurate. so, something must be amiss with the paste operation. any ideas?

    cheers!

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Code to copy cell range and paste to certain sheet

    When I tested it, it worked? Can you provide a sample with a more accurate depiction of what you are trying to do?

  12. #12
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    hello!

    sure, here it is. data has been replaced due to confidentiality reasons. to clarify things a bit, in the second sheet there is the data i want to paste, only from the subtotal rows. i have numbered the subtotals starting with 1(one) on each column, there are 3 levels of subtotals.

    also, here is the tweaked code i used for this. i used a fixed range as paste target range, because that table will remain unchanged always.

    Please Login or Register  to view this content.
    examplesheet.xlsx

    cheers!
    Last edited by goguneon; 08-30-2013 at 03:00 PM. Reason: typo

  13. #13
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Code to copy cell range and paste to certain sheet

    See if this helps?

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 08-30-2013 at 03:39 PM.

  14. #14
    Registered User
    Join Date
    07-08-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Code to copy cell range and paste to certain sheet

    as far as i can tell, all it does is place the cursor in the "infosheet" at the end of the used range on column b. that's it.

  15. #15
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Code to copy cell range and paste to certain sheet

    From your last example if you clear out the fields in your Summary Sheet 2. When I tested it, if there was a "Subtotal" in Column B, then it copied the requested data to Summary Sheet 2? Maybe I still don't understand what you want.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA code to copy cell value and paste in different sheet
    By mubashar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 01:26 AM
  2. [SOLVED] copy-paste-selected-cell-range-another-sheet
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-26-2013, 06:12 AM
  3. VBA code to copy and paste range based on separate cell value
    By Mhofu in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-01-2012, 03:03 PM
  4. Vba code to copy and paste second visible cell to other worksheet range then the next
    By Justin25150 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2012, 09:03 AM
  5. Replies: 8
    Last Post: 03-01-2012, 02:44 PM

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