+ Reply to Thread
Results 1 to 10 of 10

Looping through & cutting and pasting values between two dates

  1. #1
    Registered User
    Join Date
    05-25-2014
    Posts
    34

    Looping through & cutting and pasting values between two dates

    Hi,

    I am trying to cut all rows with the date less than 2 days older than the current date. Cut and paste it into a new worksheet in same workbook and save it into a specific folder.

    Here is my code:

    Please Login or Register  to view this content.
    I am getting an error on the line :
    Please Login or Register  to view this content.
    Saying Object doesn't support this property or method.

    Any ideas how I can solve this?

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: Looping through & cutting and pasting values between two dates

    Hello ShaliniGomes,

    I don't see anything wrong with the macro syntax. If the values in the cells were not valid dates you would receive a type mismatch error.

    You should post a copy of the workbook for further review.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-25-2014
    Posts
    34

    re: Looping through & cutting and pasting values between two dates

    Dummy Workbk.xlsm

    Hi this is a dummy workbook. So I want only the dates from current date to current date-2 to be cut and pasted into new worksheet.

    Thanks for your help.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: Looping through & cutting and pasting values between two dates

    Hello ShaliniGomes,

    Did you really want to create a separate worksheet for each date?

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: Looping through & cutting and pasting values between two dates

    Hello ShaliniGomes,

    I did find the error. in your code you have If .Cell(i, 1).Value < StartDate Then

    It should be If .Cells(i, 1).Value < StartDate Then

  6. #6
    Registered User
    Join Date
    05-25-2014
    Posts
    34

    re: Looping through & cutting and pasting values between two dates

    Thank you Leith Ross,

    I have another error:

    Please Login or Register  to view this content.
    on line
    Please Login or Register  to view this content.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: Looping through & cutting and pasting values between two dates

    Hello ShaliniGomes,

    This worked for me.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-25-2014
    Posts
    34

    re: Looping through & cutting and pasting values between two dates

    Thankk you so much!!! Amazing

  9. #9
    Registered User
    Join Date
    05-25-2014
    Posts
    34

    Re: Looping through & cutting and pasting values between two dates

    Hi so I have run into an unexpected problem.

    with this code

    Please Login or Register  to view this content.
    It gives a type error when I have the word "1 target" on column A more than once. I have the word "1 target" about 1000 times down column A and then the date begins on column A. So I want the code to ignore the word "1 target". I put it into the if statement and said
    Please Login or Register  to view this content.
    but it gave me an error.

    Any help please?

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Looping through & cutting and pasting values between two dates

    Hello ShaliniGomes,

    The macro will now check if the contents of the cells in column "A" are dates. If the cell is not a date then it is ignored.
    Please Login or Register  to view this content.

+ 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. cutting and pasting data
    By heathiep in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2012, 07:37 PM
  2. cutting and pasting in VBA
    By ben5496 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2011, 05:07 PM
  3. Cutting and Pasting Cells
    By ross88guy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2010, 11:12 AM
  4. Cutting and pasting cells
    By Hitch75 in forum Excel General
    Replies: 3
    Last Post: 08-19-2010, 07:45 AM
  5. Automatic cutting and pasting
    By gdelreal99a in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-27-2007, 09:38 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