Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi martin
tried to do something, should work! gimme some feedback if everythings fine! '----------------------------------------------- Sub martin() Dim X1, X2, Y1, Y2, XTemp As Single Dim cell_ As Integer X2 = Range("H11").Left cell_ = 11 Do While ActiveSheet.Range("E" & cell_) < "" And ActiveSheet.Range("G" & cell_) < "" And ActiveSheet.Range("F" & cell_) < "" For I = o To 2 X1 = X2 Y1 = Range("H" & cell_).Top + Range("H" & cell_).Height / 2 If I < 2 Then Y2 = Y1 XTemp = X1 X2 = X2 + (Cells(cell_, 5 + I) * (Range("H" & cell_).Width / Range("H9"))) ActiveSheet.Shapes.AddLine(X1, Y1, X2, Y2).Select Else Y2 = Y1 + Range("H" & cell_).Height X2 = XTemp + (Cells(cell_, 5 + I) * (Range("H" & cell_).Width / Range("H9"))) ActiveSheet.Shapes.AddLine(XTemp, Y1, X2, Y2).Select End If Selection.ShapeRange.Line.DashStyle = Choose(I + 1, msoLineSolid, msoLineDashDot, msoLineRoundDot) Next I cell_ = cell_ + 1 Loop End Sub '------------------------------------------------ Cheers and a nice weekend Carlo " wrote: 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. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
For Each ... Next loop - need to reference the loop variable | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Loop Function unable to loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming |