I have the following problem:
I need to highlight period of production order start and finish week, through all columns - as you see in header, there are a lot of production orders.
Is it possible with vba?
Second problem:
Each production line has time capacity, so production minutes should be divided by chosen production line weekly capacity by the end of highlighted period.
This is also need to be done on button click e.g. with vba, or formulas, but I have no idea where to place those formulas, because whole table and header supposed to be dynamic - production plan updates weekly.
UPDATE:
Here's code, that inserts formula in order manufacturing period from start to finish week, i need to loop it through all columns and insert this formula according to following orders start and finish week. And I have no idea how to do that, so help is very appreciated :)
Sub test()
Dim Rng, Rng2, Rng3 As Range
Dim v1, v2 As String
x = Range("E8")
w = Range("E11")
'Search Column or range
With Sheets("forecast").Range("D:D")
Set Rng = .Find(What:=x, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
Set Rng2 = .Find(What:=w, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
'MsgBox Rng.Offset(0, 1).Address
'MsgBox Rng2.Offset(0, 1).Address
v1 = Rng.Offset(0, 1).Address
v2 = Rng2.Offset(0, 1).Address
Range(v1 & ":" & v2).Select
Selection.formula = "=E$12/(E$10-E$7)"
Selection.NumberFormat = "0"
End With
End Sub
Example of production plan:
http://postimg.org/image/3vkx0fv5d/ http://s8.postimg.org/cdud4s1o4/stack3.jpg