kylefoley76
Well-known Member
- Joined
- Mar 1, 2010
- Messages
- 1,553
The following macro works only about 80% of the time. I'm pretty sure the problem lies with the 3rd party software xlwings. I'm using xlwings to call Excel. The Macro is so simple that I seriously doubt the problem lies with Excel. Then again, I don't see why there should be a problem with xlwings since all it does is just input the values into the subroutine. Perhaps there is a more reliable VBA way of doing things.
Sub input_into_time(rw As Integer, col As Integer, val As String):
Dim time2 As Workbook, arr1 As Variant
Dim tmsheet As Worksheet
Set time2 = Workbooks("time2.xlsx")
Set tmsheet = Worksheets("time")
tmsheet.Cells(rw, col) = val
End Sub
I get a subscript out of range error on line
Set tmsheet = Worksheets("time")
And clearly there is a sheet named time in the workbook 'time2.xlsx'
I've also tried:
Sub input_into_time3(rw As Long, col As Long, val As String):
Application.ScreenUpdating = False
Workbooks("time2.xlsx").Activate
Sheets("time").Activate
Cells(rw, col) = val
Application.ScreenUpdating = True
Sub input_into_time(rw As Integer, col As Integer, val As String):
Dim time2 As Workbook, arr1 As Variant
Dim tmsheet As Worksheet
Set time2 = Workbooks("time2.xlsx")
Set tmsheet = Worksheets("time")
tmsheet.Cells(rw, col) = val
End Sub
I get a subscript out of range error on line
Set tmsheet = Worksheets("time")
And clearly there is a sheet named time in the workbook 'time2.xlsx'
I've also tried:
Sub input_into_time3(rw As Long, col As Long, val As String):
Application.ScreenUpdating = False
Workbooks("time2.xlsx").Activate
Sheets("time").Activate
Cells(rw, col) = val
Application.ScreenUpdating = True