Results 1 to 9 of 9

Thread: Average values within time range for matching header

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Regular
    Joined
    Mar 2014
    Posts
    25
    Location

    Help with Code

    Sam,

    You gave me a great head start. I took your code and modified it to loop it through the column headers by matching them within the two files , averaging them and then pasting them. There still seems to be some error within the time range loop . Example : Row 12 in Data file has a timestamp of " 02:38:10 " lies between the timestamp of " 02:30:00 & 02:44:59 ", however the average for that row/range is being copied under the timestamp " 00:30:00 & 00:44:59 " Row 5. it shouldn't be the case. The first 2 rows of the Table file are filled accurately as per the code while taking values from Data file.
    I know that the below lines of code need to be modified however i can't seem to figure out . Hence I need your help one more time respected Sir. Please and Thank You.
    For Each taCell In taTimesRng    taStartTime = taCell
        taEndTime = taCell.Offset(, 1)
        taCellRow = taCell.Row
         
        Set daStartCell = daEndCell
         
        Do While daStartCell < taStartTime
            Set daStartCell = daStartCell.Offset(1)
        Loop
         
        Set daEndCell = daStartCell
         
        Do While daEndCell.Offset(1) <= taEndTime
        'Do While daEndCell.Offset(1) <= taEndTime
            Set daEndCell = daEndCell.Offset(1)
        Loop
    I am reattaching the two sheets with updated code in the "Table" File Module 1.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

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