+ Reply to Thread
Results 1 to 2 of 2

VBA Loop to check if a date is between two dates

  1. #1
    Registered User
    Join Date
    07-19-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA Loop to check if a date is between two dates

    Hello,
    I have a VBA Macro that is checking whether or not a date is between two other dates (located on another tab) and if so, then returning the hours from the cell below. It should loop through the two rows of dates until it finds the date it is between and return the corresponding hours.
    Below is the code:
    Please Login or Register  to view this content.
    When I step through the macro line by line it seems to work fine, however, the end result seems to provide only 3 result numbers (which two of the three are incorrect).
    Please help. Thanks in advance!
    Last edited by Leith Ross; 07-26-2010 at 07:37 PM. Reason: Added Code Tags

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: VBA Loop to check if a date is between two dates

    Your loop is set up very confusingly. Why do you loop through C = 1 to ColumnCount, but you don't use C in any of your calculations? Find a way to combine the variable in your loop with PeriodColumn and HoursColumn, then I'd guess you'll find the solution to your problem.

    Or, you could post your workbook.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

+ 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