Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: does anyone see what is wrong with this code

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    Jason in Boston MA
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  2. #2
    MrExcel MVP Anne Troy's Avatar
    Join Date
    Feb 2002
    Location
    Westwood NJ
    Posts
    2,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    MS Technet has a few articles that could apply...but this seems most likely.

    http://support.microsoft.com/search/...;en-us;Q213395

    ~Anne Troy

  3. #3
    New Member
    Join Date
    Apr 2002
    Location
    Jason in Boston MA
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    thanks, that seemed to work I still don't know why this suddenly became an issue have been usingthis code for a while.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •