Monday, 15 June 2015

VBA Loop in Excel wont recognize time -


I am creating a spreadsheet that allows users to copy the events during a specific 15-minute interval for specific sheets in the workbook. Will allow. The time interval runs from midnight to 23:45 This code works well to copy anything that happens before or before 6:45 or before, but after that nothing comes not only empty but I manually data Is checked and definitely there are incidents on the primary sheet after 6:45 and it should be copied, the data is being pulled from all the same Oracle table, hence the timing should be same.

Here's a piece of code that actually works:

  'core-orange 06:45 if ActiveCell.Address = "$ AC $ 6" then Range ("AC6"). = Value = 0 then "no exceptions have been reported" Other: Sheets ("exception"). Range ("A4", "H50") Clear Sheet ("Core"). I = 2 X = 4 Select Sheets ("Core"). Range ("A" & I) Value & lt; & Gt; "" If Range ("J" & amp; I) Price & lt; = Timezone (6, 45, 0) and range ("K" & I) Value & gt; Timelines (6, 45, 0) Then range ("A" and I, "H" and I). Select the selection. Copy Sheet ("Exception") Select Range ("A" and "X"). Select ActiveSheet Choose. I = I + 1x = X + 1 sheets ("core"). Choose another option: Sheet ("Exception"). Choose Range ("A1"). Select I = I + 1 end if the loop end is expired  

Here is the code that is not working:

  'core - orange 07:00 If ActiveCell.Address = "$ AD $ 6" then Category ("AD6"). Value = 0 then MSBBC "No exceptions reported" Other: Sheet ("Exception"). Range ("A4", "H50") Select Sheet ("Core"). I = 2x = 4 while sheets ("core"). Range ("A" & I) Value & lt; & Gt; "" If Range ("J" & amp; I) Value & lt; = Timezone (7, 0, 0) and range ("K" & amp; Value & gt; Time range (7, 0, 0) Then range ("A" and I, "H" and I). Select the selection. Copy Sheet ("Exception") Select Range ("A" and "X"). Select ActiveSheet Choose. I = I + 1x = X + 1 sheets ("core"). Choose another option: Sheet ("Exception"). Choose Range ("A1"). Select I = I + 1 end if the loop end is expired  

Two codes must be identical except for initial cells which I updated. I have tried to use different time formats but it was not going to work for anything, any help or suggestions, how to get past it would be greatly appreciated.


No comments:

Post a Comment