+ Reply to Thread
Results 1 to 4 of 4

VB Code to copy and paste range to certain sheet based on cell Value

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to copy and paste range to certain sheet based on cell Value

    Hello:

    Please refer to attached file.

    I have payroll data as shown in sheet "Payroll" in Range ("A2:H20") where Column H is SToreName.

    I need VB Code to perform following.

    Go thru loop and need to copy and paste
    range A:H at cell A21, then the result generated in range A27:M41 needs to be pasted at Sheet named in cell Column H at first available cell in column A.

    I have manually performed this as follows.
    Copied A2:H2 and pasted at cell A21, this generated data in Range A27:M41.
    Since H2 is "LJ" Then i copied this range in sheet "LJ" at A1.

    Copied A3:H3 and pasted at cell A21, this generated data in Range A27:M41.
    Since H3 is "LJ" Then i copied this range in sheet "LJ"at A16 (This was 1st available blank cell in column A).

    Copied A4:H4 and pasted at cell A21, this generated data in Range A27:M41.
    Since H4 is "WE" Then i copied this range in sheet "WE"at A1 (This was 1st available blank cell in column A).

    Copied A5:H5 and pasted at cell A21, this generated data in Range A27:M41.
    Since H5 is "LJ" Then i copied this range in sheet "LJ"at A31 (This was 1st available blank cell in column A).


    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VB Code to copy and paste range to certain sheet based on cell Value

    This should work for you. Copy to your standard code module1.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to copy and paste range to certain sheet based on cell Value

    Hello JLGWHiz:

    Thanks a lot, It works great.
    Would it be possible to go one step further and copy each store data (whole sheet by selecting Ctrl+A )in text file and store at C:\Temp\ with FileName :StoreName.iif

    In this case i will have 2 files saved at C:\Temp\LJ.iif and C:\Temp\WE.iif

    Once again thanks a lot for great help.

    Riz

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VB Code to copy and paste range to certain sheet based on cell Value

    I am not familiar with the .iif file extension, so not sure how to do that with vba. But you cant try this and see if it works.

    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 11-22-2019 at 03:54 PM.

+ 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. [SOLVED] Copy Paste a Range of Values from a Different Sheet Based on Value Entered in Cell
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-13-2015, 04:53 PM
  2. VBA code to copy paste a range based on a condition
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2014, 04:29 AM
  3. VBA Code to copy cell range and paste to certain sheet
    By goguneon in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-03-2013, 08:35 AM
  4. Replies: 0
    Last Post: 07-16-2013, 05:22 AM
  5. Code to copy and paste row from one excel sheet to another, based on criteria
    By CamSeren in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-25-2013, 04:32 AM
  6. 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
  7. Finding a named range based on cell value and copy/paste to same sheet?
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2006, 06:25 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