M
mlcs
Hi!
I new to VBA programming.... so sorry about my ignorence...
I've made the following code which draws a time diagram, each step
containing three lines. Manual labor, machine time and movement. So far
it's working well, Step 1 starts in H11 and depending on the values in
E11, F11 and G11 step 1 draws two horizontal lines and a diagonal.
First manual, then machine, and finally it draws movement - if movement
= 0 then it draws a horizontal line to the row below, else it draws a
diagonal line.
What I need:
Instead of having 50 steps I need it to take one step and loop (because
I have everything between 20-50 steps).
I need it to reed the values:
E11, F11, G11 (if all = 0 the stop looping, else move on to
E12, F12, G12
I hope some you can help.....
Thank you..... Martin
'Step 1
'manual
X1 = Range("H11").Left
X2 = X1 + (Range("E11") * (Range("H11").Width / Range("H9")))
Y1 = Range("H11").Top + Range("H11").Height / 2
ActiveSheet.Shapes.AddLine(X1, Y1, X2, Y1).Select
'machine
X3 = X2 + (Range("F11") * (Range("I11").Width / Range("H9")))
ActiveSheet.Shapes.AddLine(X2, Y1, X3, Y1).Select
Selection.ShapeRange.Line.DashStyle = msoLineDash
'movement
X4 = X2 + (Range("G11") * (Range("I11").Width / Range("H9")))
Y2 = Y1 + Range("H11").Height
ActiveSheet.Shapes.AddLine(X2, Y1, X4, Y2).Select
Selection.ShapeRange.Line.DashStyle = msoLineRoundDot
'Step 2
'manual
X5 = X4 + (Range("E12") * (Range("H12").Width / Range("H9")))
ActiveSheet.Shapes.AddLine(X4, Y2, X5, Y2).Select
'machine
X6 = X5 + (Range("F12") * (Range("H12").Width / Range("H9")))
ActiveSheet.Shapes.AddLine(X5, Y2, X6, Y2).Select
Selection.ShapeRange.Line.DashStyle = msoLineDash
'movement
X7 = X5 + (Range("G12") * (Range("H12").Width / Range("H9")))
Y3 = Y2 + Range("H12").Height
ActiveSheet.Shapes.AddLine(X5, Y2, X7, Y3).Select
Selection.ShapeRange.Line.DashStyle = msoLineRoundDot
.... and so on.
I new to VBA programming.... so sorry about my ignorence...
I've made the following code which draws a time diagram, each step
containing three lines. Manual labor, machine time and movement. So far
it's working well, Step 1 starts in H11 and depending on the values in
E11, F11 and G11 step 1 draws two horizontal lines and a diagonal.
First manual, then machine, and finally it draws movement - if movement
= 0 then it draws a horizontal line to the row below, else it draws a
diagonal line.
What I need:
Instead of having 50 steps I need it to take one step and loop (because
I have everything between 20-50 steps).
I need it to reed the values:
E11, F11, G11 (if all = 0 the stop looping, else move on to
E12, F12, G12
I hope some you can help.....
Thank you..... Martin
'Step 1
'manual
X1 = Range("H11").Left
X2 = X1 + (Range("E11") * (Range("H11").Width / Range("H9")))
Y1 = Range("H11").Top + Range("H11").Height / 2
ActiveSheet.Shapes.AddLine(X1, Y1, X2, Y1).Select
'machine
X3 = X2 + (Range("F11") * (Range("I11").Width / Range("H9")))
ActiveSheet.Shapes.AddLine(X2, Y1, X3, Y1).Select
Selection.ShapeRange.Line.DashStyle = msoLineDash
'movement
X4 = X2 + (Range("G11") * (Range("I11").Width / Range("H9")))
Y2 = Y1 + Range("H11").Height
ActiveSheet.Shapes.AddLine(X2, Y1, X4, Y2).Select
Selection.ShapeRange.Line.DashStyle = msoLineRoundDot
'Step 2
'manual
X5 = X4 + (Range("E12") * (Range("H12").Width / Range("H9")))
ActiveSheet.Shapes.AddLine(X4, Y2, X5, Y2).Select
'machine
X6 = X5 + (Range("F12") * (Range("H12").Width / Range("H9")))
ActiveSheet.Shapes.AddLine(X5, Y2, X6, Y2).Select
Selection.ShapeRange.Line.DashStyle = msoLineDash
'movement
X7 = X5 + (Range("G12") * (Range("H12").Width / Range("H9")))
Y3 = Y2 + Range("H12").Height
ActiveSheet.Shapes.AddLine(X5, Y2, X7, Y3).Select
Selection.ShapeRange.Line.DashStyle = msoLineRoundDot
.... and so on.