Results 1 to 5 of 5

Thread: Excel VBA - help with selecting

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    7

    Excel VBA - help with selecting

    I have to make a query statement for a search criteria.
    I am going to get a start date and end date from the user using date picker.
    I wanted to select all the rows and copy them into a new sheet based on a date range from a column which has date.

    I am not able to come up with a query statement. Is there an easy way to do it? I am new in VBA, so any help in this regard will be really appreciated.

    Thanks in advance.

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Excel VBA - help with selecting

    You really don't need a query to do this. Write a procedure that performs the following steps.
    1/ Get the Start and End Dates
    2/ Sort the source data by the Date column
    3/ Find the first instance of the Start Date and record the row number
    4/ Find the last instance of the End Date and record the row number
    5/ Copy all the data between these rows
    6/ Create a new worksheet
    7/ Paste the data to the new sheet
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    7

    Re: Excel VBA - help with selecting

    Thanks for the reply. can you help with the procedure? I am new to VBA as I said before, so I am finding it difficult to get the code for the procedure.

    Thanks once again for your reply.

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Excel VBA - help with selecting

    Of course I can help with the procedure, everyone here can. But you need to try it first, then post specific questions here when you get stuck. Trial and error is one of the best learning techniques there is, reading the VBA help files is one of the other best ways.

    Start by reading the help file on the SORT method of the RANGE object in Excel. This will help with step 2.
    Then read the help on the FIND method of the RANGE object. this will help with steps 3 and 4.
    Then the COPY method.
    Then the NEW method of the worksheets collection.
    Then the PASTE method.

    I'm not trying to be difficult here, but if you don't try it yourself first you probably wont understand the code I give you and will not learn anything by the experience.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    7

    Re: Excel VBA - help with selecting

    Thanks for the help. I will try to get the code done and will buzz you.
    Once again thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width