+ Reply to Thread
Results 1 to 6 of 6

Macro to copy rows from one sheet to another based on selected date range

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003
    Posts
    93

    Macro to copy rows from one sheet to another based on selected date range

    Hello experts
    I am attaching herewith an Excel file which contains 5 sheets.

    It contains a sheet called Periodic Data. In this i am entering From & To dates and click on the command button.
    It copies the rows from MAST sheet where the Left Port is >=From Date and <=To date.

    The code is working , but the problem is of speed.

    The date range can be of 1 week , 2 week , 1 month , 6 months & so on.
    The problem is greater the period, the more number of rows are to be copied and more time it takes to run the code.

    Please have a look and suggest something to improve the speed.

    Kmahesh
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Macro to copy rows from one sheet to another based on selected date range

    Try this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    09-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Macro to copy rows from one sheet to another based on selected date range

    Sixthsense ,
    Its not working.
    After I click the command button it is not showing even a single record.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro to copy rows from one sheet to another based on selected date range

    Ahh, VBA and dates. Change this line:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    09-21-2012
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Macro to copy rows from one sheet to another based on selected date range

    Thank You romperstomper
    it works perfect , will u please explain what is CDb1 ?

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro to copy rows from one sheet to another based on selected date range

    CDbl converts a value to the data type Double (see data type descriptions here).

    It's necessary here because VBA will interpret a date string using US format if it can - so it would interpret your 1/4/2014 as 4th Jan 2014, not 1st April 2014. Since Excel stores dates as numbers (the number of days from 1/1/1900), using CDbl converts the date value into the number 41730 which cannot be misinterpreted.

+ 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. Macro to copy rows based on moving date and paste the rows into an identical sheet
    By ivandc1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2014, 11:59 AM
  2. [SOLVED] Copy Rows To Predefined Sheet Based on Date Range Using Form or Message Box
    By Isacc in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 02-06-2013, 09:25 AM
  3. Copy rows to new sheet based on date range selected on a form
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-19-2009, 11:40 AM
  4. Copy Rows from selected Sheet to New Sheet based on Cell Value
    By joemcmillen in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-03-2008, 03:44 PM
  5. Copy Rows In New Sheet Based On Date Range Criteria
    By ahmedwaseem2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2006, 05:45 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