johant1957
Programmer
this is my code. I try to fill in a cell in the current excel-sheet. I work with two workbooks, one is the import-workbook, I have to do some calculations, and the "start"-workbook, where I have to fill in the results of the calculations.
Set wbWeek = ActiveWorkbook
intSheetNumber = 1
If GetOpenFileName(OFName) Then
MsgBox "File to Open: " + Trim$(OFName.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
connectionName = Trim$(OFName.lpstrFile)
Workbooks.Open connectionName
File_Path = connectionName
strname = Dir(File_Path)
intpos = InStr(strname, ".")
intpos = intpos - 1
strInvoer = Left(strname, intpos)
Set wbInbound = Workbooks.Open(strInvoer)
i = 1
Workbooks(strInvoer).Activate
Do While Workbooks(strInvoer).ActiveSheet.Range("a" & i) <> Empty
i = i + 1
Loop
j = 2
Do While j < i
Workbooks(strInvoer).ActiveSheet.Range("a" & j).Select
intPos1 = InStr(Workbooks(strInvoer).ActiveSheet.Range("a" & j), " ")
intpos2 = InStr(Workbooks(strInvoer).ActiveSheet.Range("a" & j), ":")
intPos1 = intPos1 + 1
If intpos2 - intPos1 = 1 Then
strVeldA = Workbooks(strInvoer).ActiveSheet.Range("a" & j)
intUur = Mid(strVeldA, intPos1, 1)
Else
strVeldA = Workbooks(strInvoer).ActiveSheet.Range("a" & j)
intUur = Mid(strVeldA, intPos1, 2)
End If
If intUur < 8 Then intUur0 = intUur0 + 1
If intUur = 8 Then intUur8 = intUur8 + 1
j = j + 1
Loop
wbWeek.Activate
Worksheets("woensdag").Range("D8").Select
wbWeek.ActiveSheet.Cells(8, D) = intUur0
At this last line I get the error. I changed it several times, like activesheet(1), or wbWeek.Activesheet.Range(D8) = intuur0. The result was the same error
Is there anyone who can help me??
I am using excel 2010 (office 2010)
Kind regards from the Netherlands
Set wbWeek = ActiveWorkbook
intSheetNumber = 1
If GetOpenFileName(OFName) Then
MsgBox "File to Open: " + Trim$(OFName.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
connectionName = Trim$(OFName.lpstrFile)
Workbooks.Open connectionName
File_Path = connectionName
strname = Dir(File_Path)
intpos = InStr(strname, ".")
intpos = intpos - 1
strInvoer = Left(strname, intpos)
Set wbInbound = Workbooks.Open(strInvoer)
i = 1
Workbooks(strInvoer).Activate
Do While Workbooks(strInvoer).ActiveSheet.Range("a" & i) <> Empty
i = i + 1
Loop
j = 2
Do While j < i
Workbooks(strInvoer).ActiveSheet.Range("a" & j).Select
intPos1 = InStr(Workbooks(strInvoer).ActiveSheet.Range("a" & j), " ")
intpos2 = InStr(Workbooks(strInvoer).ActiveSheet.Range("a" & j), ":")
intPos1 = intPos1 + 1
If intpos2 - intPos1 = 1 Then
strVeldA = Workbooks(strInvoer).ActiveSheet.Range("a" & j)
intUur = Mid(strVeldA, intPos1, 1)
Else
strVeldA = Workbooks(strInvoer).ActiveSheet.Range("a" & j)
intUur = Mid(strVeldA, intPos1, 2)
End If
If intUur < 8 Then intUur0 = intUur0 + 1
If intUur = 8 Then intUur8 = intUur8 + 1
j = j + 1
Loop
wbWeek.Activate
Worksheets("woensdag").Range("D8").Select
wbWeek.ActiveSheet.Cells(8, D) = intUur0
At this last line I get the error. I changed it several times, like activesheet(1), or wbWeek.Activesheet.Range(D8) = intuur0. The result was the same error
Is there anyone who can help me??
I am using excel 2010 (office 2010)
Kind regards from the Netherlands