ecoscientist
New Member
- Joined
- Apr 4, 2002
- Messages
- 12
I keep getting a "subscript out of range error" in the following piece of code. It was working fine and then suddenly started crashing. I don't see anything wrong.
Sub opentextfile()
' this routine opens a file in text format identified with the variable FILENAME!
Workbooks.OpenText FileName:=(guess & UserForm4.ListBox1), Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1))
'copy file into rawdata sheet
Range("A1:I274").Copy Destination:=Workbooks("project.xls").Sheets("RAW_DATA").Range("A1").End(xlUp)
ActiveWindow.Close ([True])
' Copy area counts column and paste it into correct instrument and level transpose it to a row
sheetselect = ("gc3_RF") 'this is added here for trouble shooting only remove when fixed
Workbooks("project.XLS").Activate
Sheets("RAW_DATA").Range("f4:f18").Copy
Sheets(sheetselect).Activate 'error occurs here
Cells(numit + 3, 2).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub
Sub opentextfile()
' this routine opens a file in text format identified with the variable FILENAME!
Workbooks.OpenText FileName:=(guess & UserForm4.ListBox1), Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1))
'copy file into rawdata sheet
Range("A1:I274").Copy Destination:=Workbooks("project.xls").Sheets("RAW_DATA").Range("A1").End(xlUp)
ActiveWindow.Close ([True])
' Copy area counts column and paste it into correct instrument and level transpose it to a row
sheetselect = ("gc3_RF") 'this is added here for trouble shooting only remove when fixed
Workbooks("project.XLS").Activate
Sheets("RAW_DATA").Range("f4:f18").Copy
Sheets(sheetselect).Activate 'error occurs here
Cells(numit + 3, 2).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub