+ Reply to Thread
Results 1 to 7 of 7

Loop through last row to return a value based on value of current cell

  1. #1
    Registered User
    Join Date
    04-12-2007
    Posts
    57

    Loop through last row to return a value based on value of current cell

    I have an extensive macro I run that I need to add some code to. For some reason it worked yesterday, today it does not. I need to find the last row of a spreadsheet that will change daily. I need to loop through column 10 if the value is a "B", it should grab the value of column 8, if it is a "W" it should grab the value of column 9, anything else it should leave blank.

    here is what I have
    Please Login or Register  to view this content.
    Last edited by sammar12; 07-07-2016 at 11:57 AM. Reason: instruction were incorrect

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop through last row to return a value based on value of current cell

    Why are you looping backwards, not forwards as you are not inserting to deleting rows?
    Filter is much more faster than a loop. Please attach a sample and will do a better code.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Loop through last row to return a value based on value of current cell

    To add to what AB33 said you may look to simplify things by putting a formula in column D rather than use a macro. Here is what i think you are trying to do

    Please Login or Register  to view this content.
    Last edited by stnkynts; 07-07-2016 at 11:26 AM.
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Registered User
    Join Date
    04-12-2007
    Posts
    57

    Re: Loop through last row to return a value based on value of current cell

    Quote Originally Posted by AB33 View Post
    Why are you looping backwards, not forwards as you are not inserting to deleting rows?
    Filter is much more faster than a loop. Please attach a sample and will do a better code.
    I have attached a file and changed my code, since I had an instruction that has nothing to do with this code left in from a previous code I took this from.

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

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop through last row to return a value based on value of current cell

    Have you tried stnkynts' code?
    Where do you want to copy the data in to where is a match of B and W? Which columns?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Loop through last row to return a value based on value of current cell

    From your code, this is probably correct.

    Please Login or Register  to view this content.
    stnkynts' code

    Please Login or Register  to view this content.
    Last edited by AB33; 07-07-2016 at 12:23 PM.

  7. #7
    Registered User
    Join Date
    04-12-2007
    Posts
    57

    Re: Loop through last row to return a value based on value of current cell

    Thanks for the help!

+ 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] Select Value in current cell while in a Loop
    By cooper.1651 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-01-2015, 09:58 PM
  2. [SOLVED] Pick a cell containing current month actulas based what the current month is.
    By vanbasten007 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-10-2014, 01:17 AM
  3. [SOLVED] check cell above current cell in loop
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-13-2013, 10:18 AM
  4. [SOLVED] Date Formula to Return Week Number in Current Month based on Reporting Period
    By jeversf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2013, 12:10 PM
  5. Replies: 11
    Last Post: 07-01-2012, 03:51 AM
  6. [SOLVED] Macro to return to Current Sheet and Cell
    By Steve Klenner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2005, 10:05 AM
  7. return dynamic current active cell!!
    By Ginola in forum Excel General
    Replies: 3
    Last Post: 06-08-2005, 02:05 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