Distributing Daily Productions on Calender

adokskel

New Member
Joined
Aug 5, 2010
Messages
9
Hello everyone,

Can this problem be solved by only functions or is it needed to write macro?

I want to distribute daily planned production quantities from starting day to deadline.

https://pasteboard.co/GOSLoSn.jpg


Thank you very much
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try this macro:
Code:
Sub DDP()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim sDate As Range
    Dim foundSDate As Range
    Dim DV1 As Date
    Dim DV2 As Date
    Dim foundEDate As Range
    Dim lColumn As Long
    lColumn = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
    For Each sDate In Range("D3:D" & LastRow)
        DV1 = DateValue(CStr(sDate))
        DV2 = DateValue(CStr(sDate.Offset(0, 1)))
        Set foundSDate = Range(Cells(2, 8), Cells(2, lColumn)).Find(What:=Format(DV1, "dd.mm.yyyy"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
        Set foundEDate = Range(Cells(2, 8), Cells(2, lColumn)).Find(What:=Format(DV2, "dd.mm.yyyy"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
        With Range(Cells(sDate.Row, foundSDate.Column - 1), Cells(sDate.Row, foundEDate.Column - 1))
            .Value = sDate.Offset(0, 3)
            .Interior.ColorIndex = sDate.Interior.ColorIndex
        End With
    Next sDate
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Sorry. I had to make one minor correction. Please use this version of the macro:
Code:
Sub DDP()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim sDate As Range
    Dim foundSDate As Range
    Dim DV1 As Date
    Dim DV2 As Date
    Dim foundEDate As Range
    Dim lColumn As Long
    lColumn = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
    For Each sDate In Range("D3:D" & LastRow)
        DV1 = DateValue(CStr(sDate))
        DV2 = DateValue(CStr(sDate.Offset(0, 1)))
        Set foundSDate = Range(Cells(2, 8), Cells(2, lColumn)).Find(What:=Format(DV1, "dd.mm.yyyy"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
        Set foundEDate = Range(Cells(2, 8), Cells(2, lColumn)).Find(What:=Format(DV2, "dd.mm.yyyy"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
        With Range(Cells(sDate.Row, foundSDate.Column), Cells(sDate.Row, foundEDate.Column - 1))
            .Value = sDate.Offset(0, 3)
            .Interior.ColorIndex = sDate.Interior.ColorIndex
        End With
    Next sDate
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top