+ Reply to Thread
Results 1 to 6 of 6

Macro to scan a column and return a value

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Macro to scan a column and return a value

    I am new to all of this and have not gotten to the point where I can figure out how to even begin to do this. I have searched quite a bit on many websites to try and find a problem similar to where I can modify the code, but I have not been able to. I can make visual/cosmetic changes in a macro, but not something like this. I desperately need help with it.

    I have a spreadsheet that that has columns from A to AE, but the amount of rows is variable every time this report is run. I need a macro that will scan or search all of the cells of column G for any date (dates and blank cells is all that will be in the column) and if a Date is found, run the formula G3-$P$1 (the G3 depends on what row the formula will be run in) in the corresponding cell in the same row in column Q. If a cell is blank in Column G, then I need it to return the value that will be in the the same row in Column P, but in Column Q. All of the other columns have values, but they are independent from these. For a visual example, I have created something below. Any help would be greatly appreciated. Thanks!


    3/27/2015
    A B C D E F G H I J K L M N O P Q
    1/1/2015 7 =G3-$P$1
    Blank, returns value of P3 in Q3 12 12

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Macro to scan a column and return a value

    orlex,

    Which column will have data for every row? can we use A? Also, the Q column calculation, do you want the formula in the cell? or the value that results from the formula?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro to scan a column and return a value

    Please Login or Register  to view this content.
    If someone has helped you then please add to their Reputation

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Macro to scan a column and return a value

    another approach:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-26-2015
    Location
    Florida
    MS-Off Ver
    Office 2007
    Posts
    25

    Re: Macro to scan a column and return a value

    Thank you both. PJ, yours was close, but slightly off. Arkadi, yours worked perfectly! Thank you both again!

  6. #6
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Macro to scan a column and return a value

    Out of interest what was mine doing wrong?

+ 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. Scan-in, Scan-out tool inventory with barcode scanner
    By rycr023 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2014, 11:52 AM
  2. Scan a row for text; return row and column header info
    By Kronote in forum Excel General
    Replies: 5
    Last Post: 06-02-2013, 06:43 PM
  3. scan range and return value if adjacent cell = something
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-20-2012, 04:05 PM
  4. scan data, find max value of column, return single record on other worksheet
    By virtualnoob in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-26-2012, 11:26 PM
  5. Macro to scan column and copy corresponding cell
    By RobbieMoulton in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2011, 12:12 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