troubleshooting Question

Copy Data with 24 hours time set

Avatar of Cartillo
CartilloFlag for Malaysia asked on
Microsoft Excel
22 Comments2 Solutions460 ViewsLast Modified:
Hi Experts,

I would like to request Experts help to add additional feature in the attached macro. Currently the macro only able to copy data from Booking sheet (cell C5) to Order sheet based on Date, Frequency and Time between 06:00 to 00:00hrs. Intent to expend the duration from 06:00am hrs to 05:50hrs (24hrs). Hope Experts will help to add this feature so that the data can be copied based on 24 hours interval.



Sub spreaddata()
With Sheets("Booking")
    sdat = CVDate(.[c7])
    edat = CVDate(.[e7])
    stim = CVDate(.[c9])
    etim = CVDate(.[e9])
    ndays = edat - sdat + 1
    'dur = (etim - stim) * ndays
    dur = (etim - stim - 0.00001) * ndays
    ns = .[c11]
    Gap = dur / (ns - 1)
End With
dat = sdat
tim = stim
For sh = 1 To ns
    cn = Sheets("Order").Range("2:2").Find(dat).Column
    rn = (tim - 0.25) * 24 * 6 + 3
    Sheets("Order").Cells(rn, cn) = Sheets("Order").Cells(rn, cn) & vbCrLf & Sheets("Booking").[c5]
    If tim + Gap > etim Then
    dat = dat + 1
    tim = tim + Gap - etim + stim
    Else
    tim = tim + Gap
    End If
Next sh
End Sub
OrderList.xlsm
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 22 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros