+ Reply to Thread
Results 1 to 5 of 5

Copy data range to another range on the same sheet if criteria is met

  1. #1
    Registered User
    Join Date
    06-18-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2013/2016
    Posts
    40

    Copy data range to another range on the same sheet if criteria is met

    Hi,

    I have a range of data (C3:S36) that corresponds to a particular week. The week number is in cell A5. The range C3:S36 on my master file contains INDEX MATCH formulas bringing summary data in from another sheet and changes depending on the week selected in the other sheet from a dropdown. I have removed the formulas in the example file attached

    What I would like to do is copy the the values from range (C3:S36) with code and paste it into pre-defined ranges below. So, if for example in my attached file the week number in cell A5 is 36 it would look down column A until it finds the matching week number (Cell A1263) and automatically copy range C3:S36 into range C1263:S1296.

    Thanks very much for any help on this, my VBA knowledge is sadly lacking I'm afraid. I aim to do the Chandoo.org VBA course at some point soon but at the moment my work commitments won't allow me enough time unfortunately. I do appreciate any help you can give me.

    Thanks

    Grizz
    Attached Files Attached Files

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Copy data range to another range on the same sheet if criteria is met

    Hi Grizz,
    try it
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-18-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2013/2016
    Posts
    40

    Re: Copy data range to another range on the same sheet if criteria is met

    Hi nilem,

    That worked great when I first tried it, it populated week 36's data C1263:S1296, then I tried Week 37 and I'd gone down to Week 37 already to see the data come in and again it worked. Then I typed in 38 to Cell A5 and then went down and there was nothing there. I looked at the code and realised it was getting the selected week from the combo box which I had called WEEK (I was just using that to navigate to the range). I would like it to get the week number from Cell A5 as that will automatically change when the user selects the week in the other sheet and all the data changes in the range C3 to S36. I guess instead of looking at the value in the combo box it needs to look at the the value in Cell A5, how would I change the code to do that?

    Also, is it possible that I could put the code on a 'sheet change event' when cell A5 changes even though it won't be the active sheet when the week is selected on the other sheet? I'm trying to make things happen as automatically as possible as the workbook is for other people to use.

    Thanks for your help..

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Copy data range to another range on the same sheet if criteria is met

    Ok, then try to change the value in cell A1 on "Sheet1" and look at your "Weekly Summary1" on the corresponding row
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-18-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2013/2016
    Posts
    40

    Re: Copy data range to another range on the same sheet if criteria is met

    Hi nilem,

    Sorry for the late reply...I had a rugby game to go to yesterday afternoon. Your solution works perfectly for what I need to do, thank you very much. I'll now study your code and see if I can work out what's going on to do that. I will mark the thread as solved and give you your deserved REP but would you mind if after looking at your code I ask you any questions about it, I am keen to learn VBA?

+ 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. Replies: 4
    Last Post: 07-24-2012, 07:09 AM
  2. [SOLVED] Copy Range of Cells to Another Sheet Based on Criteria
    By hedefinesme in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2012, 02:04 AM
  3. Copy Data based on a Range of Criteria
    By vbait in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-27-2010, 07:35 PM
  4. Copy data to a sheet based on criteria in a range
    By cschaaf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2009, 11:36 PM
  5. Copy Rows In New Sheet Based On Date Range Criteria
    By ahmedwaseem2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2006, 05:45 AM

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