+ Reply to Thread
Results 1 to 6 of 6

Conditional Shifting Cells to the Left Macros

  1. #1
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Conditional Shifting Cells to the Left Macros

    The following is my last question for today:

    In Row B I have a list of dates such as "Dec-31-2006", "Dec-31-2007", "Dec-31-2008","Dec-31-2009".
    These dates begin in Cell B5.

    I would like to create the following Macros:
    If the function Right(B5,4) is less than 2008, delete B5:B21 by shifting cells to the left. Then I want the same condition to run again on the new B5 (from the cells that got shifted in), until there is a point where the function Right(B5,4)=>2008.

    I want this Macros to run on all worksheets within my workbook. As a result there are some worksheets that might have an empty B5. I do not want these worksheets to have the macros run on them

    Thank you so much for looking at my query.
    Last edited by undergraduate; 01-13-2011 at 07:25 AM.

  2. #2
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Conditional Shifting Cells to the Left Macros

    I have uploaded a sample worksheet showing before and after data in running the previously described macros if it is helpful since I may not have been very clear in my earlier post.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Conditional Shifting Cells to the Left Macros

    see attachment, run macro "Less2008"
    Attached Files Attached Files
    Last edited by watersev; 01-12-2011 at 08:35 PM.

  4. #4
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Conditional Shifting Cells to the Left Macros

    Hi thanks so much for your help.
    I do have one question however.

    I found out that some of the B5 cells might have words in it where right(b5)= pure text (all letters), i.e. its not equal to a year (which is a 4 digit number). I was wondering if there is any way to account for this exception , and skip the sheets where Right(b5) is not equal to all numbers.

    Sry for not stating this earlier.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Conditional Shifting Cells to the Left Macros

    see attachment
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    01-28-2010
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    105

    Re: Conditional Shifting Cells to the Left Macros

    Thank you good sir!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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