+ Reply to Thread
Results 1 to 6 of 6

load data into array, check condition, and paste back into sheet

  1. #1
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    load data into array, check condition, and paste back into sheet

    Hi all,

    I want to check the condition of multiple cells in a range without creating a helper column (for convenience and to learn more about VBA).

    In my sample file, column A will stay the same, but values in column B have to be adjusted based on my condition (cell in column B divided by cell in column A should not exceed 0.95). I created two helper columns to illustrate what I want to achieve. Column C uses the cell reference of column B to check for the condition, whereas column D uses the cell value of column B instead. I assume this could be done with code by loading the values of column B into an array, then checking if the condition is met and pasting it back into the range?
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: load data into array, check condition, and paste back into sheet

    What should happen if a cell in col B doesn't meet the criteria? change its value to 'warning'?

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,694

    Re: load data into array, check condition, and paste back into sheet

    Try on a copy of your workbook.
    Changes the values in Column B to 95 percent if it is more.
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: load data into array, check condition, and paste back into sheet

    How should the values in column B be 'adjusted'?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    Re: load data into array, check condition, and paste back into sheet

    Quote Originally Posted by jolivanes View Post
    Try on a copy of your workbook.
    Changes the values in Column B to 95 percent if it is more.
    This was a very good starting point! Thanks jolivanes!!

    Below is what seems to work for me now, even though not sure if it's the most efficient solution.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    Re: load data into array, check condition, and paste back into sheet

    Quote Originally Posted by Akuini View Post
    What should happen if a cell in col B doesn't meet the criteria? change its value to 'warning'?
    Yes, exactly! If the value exceeds 0.95 it should paste the string "Warning!". I simplified the actual output for explanation purposes.

+ 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. check condition in a loop and store results in an array
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-23-2018, 07:00 AM
  2. Replies: 4
    Last Post: 02-09-2016, 03:23 PM
  3. [SOLVED] 2D Array Lookup and Condition Check
    By JYTS in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 12-06-2015, 09:29 PM
  4. [SOLVED] VBA to find data in Sheet 2 copy and paste back in Sheet 1
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2014, 09:39 PM
  5. Replies: 1
    Last Post: 09-17-2013, 01:38 PM
  6. [SOLVED] Read range into an array, work with it, then paste it back to a sheet.
    By wolis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2012, 10:07 AM
  7. [SOLVED] Load an array with Sheet names
    By S G Booth in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-02-2005, 05:06 PM

Tags for this Thread

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