Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error 1004 runtime error

Status
Not open for further replies.

johant1957

Programmer
Nov 30, 2009
4
NL
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
 
Use either this:
wbWeek.ActiveSheet.Cells(8, [!]"[/!]D[!]"[/!]) = intUur0
or this:
wbWeek.ActiveSheet.Range("D8") = intUur0

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top