Several ingredients to improve:
Try to get the grips of below code sequence:
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSH As Excel.Worksheet
Dim oRng As Excel.Range
Dim xlNotRun As Boolean
Dim iRow As integer
Dim iCol as integer, iStart as integer
iStart = 1
On Local Error GoTo xlNotRunning
Set oXL = GetObject(, "Excel.Application")
bmkOpenWorkbook:
Set oWB = _
oXL Workbooks.Open(WorkbookToWorkOn)
Set oSH = Sheets("Taul1")
On Local Error Goto ErrProcessingSheet
For iRow = 1 to 2
For iCol= iStart to iStart + 12
'Note oRng and the TextBox representation
'in this section:
Set oRng = oSH.Cells(iRow, iCol)
oRng.FormulaR1C1 = _
Me.Controls("TextBox" & Cstr(x)).Value
Next
Next
oWB.Sheets("Kaavio1").Select
ExitHere:
On Error Resume Next
oWB.Close True
If xlNotRun The oXL.Quit
Set oRng = Nothing
Set oSheet = Nothing
Set oWB = Nothing
Set oXL = Nothing
Err.Clear
Exit Sub
xlNotRunning:
Set oXL = New Excel.Application
xlNotRun = True
Resume bmkOpenWorkbook
ErrProcessingSheet:
Msgbox "Err occurred processing worksheet" & _
"Kindly fix it" & vbCr & Err.Number & vbcr & _
Err.Description
Resume ExitHere
End Sub
Krgrds,
Perry
> Hi
>
[quoted text clipped - 66 lines]
> Range("M2").Select
> ActiveCell.FormulaR1C1 = Me.TextBox12.Value
> Range("B3").Select
> ActiveCell.FormulaR1C1 = Me.TextBox13.Value
[quoted text clipped - 21 lines]
> ActiveCell.FormulaR1C1 = Me.TextBox24.Value
> Range("M4").Select
> Sheets("Kaavio1").Select
> 'Next oSheet
[quoted text clipped - 27 lines]
> --
> Message posted via http://www.officekb.com
Perry - 12 Apr 2005 21:37 GMT
Oops, too fast:
- First For/Next Loop, raise iRow by one to read
For iRow = 2 to 3
- After second For/Next, raise iStart by 12 to read:
Next 'end of second loop
iStart = iStart + 12
Next 'end of first loop
Good luck ...
Krgrds,
Perry
> Several ingredients to improve:
> Try to get the grips of below code sequence:
[quoted text clipped - 185 lines]
> > --
> > Message posted via http://www.officekb.com
Mikko Rantanen - 13 Apr 2005 15:55 GMT
It works great after few mod's
Like setting a workbook and controls number x
Thx
Mikko