+ Reply to Thread
Results 1 to 12 of 12

How to copy number of cells if two criterias are met

  1. #1
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    How to copy number of cells if two criterias are met

    Hi,

    So, I tought this was going to be an easy one, but I am really having a hard time with this one.

    I have two cells that can have up to 8 values each (select value from a drop down list), and I have a big range (26 cells) that I want to copy to this sheet from another sheet if the criterias are met.

    So, the code will be something like:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    I have around 60 ranges I need to copy based on different different criterias, but right now, I am not able to copy one

    Thanks for any help I can get with this!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: How to copy number of cells if two criterias are met

    Might be because "50" is text as opposed to (just) 50 which is numeric.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74
    Quote Originally Posted by TMS View Post
    Might be because "50" is text as opposed to (just) 50 which is numeric.
    Thanks for reply. I have tried without "" as well.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to copy number of cells if two criterias are met

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  5. #5
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: How to copy number of cells if two criterias are met

    Hi! Of course I can upload a file! Thanks for showing interest Momps1!

    The file should now be uploaded. I have cleared sensitive information and the VBA. I have tried to explain in the file what I want to do as well.
    Attached Files Attached Files

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to copy number of cells if two criterias are met

    Start by formatting all the numbers in red on Sheet2 as 'Number' with 8 decimal places or whatever number of decimal places you want. Next copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your Sheet1 and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. First select a value in E39 and then select a value in E41.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: How to copy number of cells if two criterias are met

    Quote Originally Posted by Mumps1 View Post
    Start by formatting all the numbers in red on Sheet2 as 'Number' with 8 decimal places or whatever number of decimal places you want. Next copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your Sheet1 and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. First select a value in E39 and then select a value in E41.
    Please Login or Register  to view this content.
    Oh man! That was GREAT! That code is so far from my level, I need to study it =)

    So many thanks to you my friend!

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to copy number of cells if two criterias are met

    You are very welcome.

  9. #9
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: How to copy number of cells if two criterias are met

    Quote Originally Posted by Mumps1 View Post
    You are very welcome.
    Hi!

    So, I Have to ask for your precious advice again.
    So, the code you gave do not change the values if I just change value E39 without changing E41. Is this possible?

    Also, I tried to add another column with different values that can be seen in Sheet 2 (further down). I do not know what is wrong with the code.

    I will put both here and hope for advice

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to copy number of cells if two criterias are met

    Try:
    Please Login or Register  to view this content.
    Remember to format all the numbers on Sheet2 as 'Number' with 8 decimal places or whatever number of decimal places you want.

  11. #11
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: How to copy number of cells if two criterias are met

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    Remember to format all the numbers on Sheet2 as 'Number' with 8 decimal places or whatever number of decimal places you want.
    Thanks again my friend! Works like a charm!

    Just out of curiosity, why do I need to format the numbers with different decimal places?

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: How to copy number of cells if two criterias are met

    You are very welcome. The number of decimals will determine how they are displayed on your sheet.

+ 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: 1
    Last Post: 06-25-2019, 03:00 PM
  2. [SOLVED] Several criterias (13) + return single number
    By vill in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-13-2017, 10:04 PM
  3. [SOLVED] Macro Find set criterias to a colomn of number, delete the rows that don't meet criterias
    By TAMMY32 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-03-2017, 04:09 PM
  4. Count number of values with two criterias
    By Jonathan9 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-03-2015, 03:17 PM
  5. Replies: 2
    Last Post: 02-01-2015, 10:18 AM
  6. [SOLVED] Copy set number of cells a set number of times within same worksheet
    By hal9000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2013, 11:51 AM
  7. calculate number of cells with two criterias
    By jojojojo in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-15-2013, 02:36 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