+ Reply to Thread
Results 1 to 6 of 6

How to make a loop that calculates against a time field

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    Toledo, OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    How to make a loop that calculates against a time field

    Hello,
    Thanks in advance for assistance (vb newbie). In order to prepare data for a freq distribution histogram for a day, I believe that I 1st need to pass my data through a VB loop to transform my data (once it is transformed I can handles the frequency distribution histogram. However, it is the VB loop in excel that gives me grief since I have never built one before).

    To make this simple to understand, my current data set looks like this (1st set below... data set is updated constantly so every day I open the spreadsheet the data will have new additions and occasional modifications):
    Report_Id Launch_Time Frequency_PerDay Interval(hrs)
    1 06:00 2 12
    2 07:00 1 1
    3 08:10 3 4

    My goal is to make the data (above) look like this (below) so that my report launch times are distributed over a 24 hour period (reveals the daily schedule):
    Report_ID LaunchTime
    1 06:00
    2 07:00
    3 08:10
    3 12:10
    3 16:10
    1 18:00

    How would the loop code look to transform the 1st data set into the second data set?
    Thanks!
    Dave

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: How to make a loop that calculates against a time field

    I found it quite difficult getting this to work, this is the best I've come up with. You may need to change it to suit where your data is stored. This will look at data on "Sheet1" in columns A to D and write data to "Sheet2" in columns A and B.

  3. #3
    Registered User
    Join Date
    05-28-2013
    Location
    Toledo, OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to make a loop that calculates against a time field

    Thanks yudlugar.

    When you say "...This will look at data on "Sheet1" in columns..." Is there an example or something I should be able to see to understand what you mean (I am a newbie. Apologies if there is a link or some other way to view your example that I am simply not recognizing). Thanks again! Dave

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: How to make a loop that calculates against a time field

    No, I forgot to put the code on the post, oops. I'll do it again later.

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: How to make a loop that calculates against a time field

    Ok, this was the code I used:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-28-2013
    Location
    Toledo, OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to make a loop that calculates against a time field

    Excellent. I've learned so much by 1st attempting to code this myself, and then by seeing how you actually did it. I am going to attempt to use your code this afternoon. I'll let you know how it comes out. Thanks again for sharing your knowledge and skills here!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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