+ Reply to Thread
Results 1 to 4 of 4

Macro not working correctly

  1. #1
    Registered User
    Join Date
    06-10-2004
    MS-Off Ver
    Office 2003
    Posts
    70

    Macro not working correctly

    Morning Clever People!

    I have a very simple macros that I recorded and sits in my personal.xls.

    I've now copied it into another worksheet and am getting strange results. The strangeness happens in the first two lines!

    Sub Val_Hit_Rate()

    Workbooks.OpenText Filename:="t:\TmpRpts\HIT_SCR1.900", Origin:=xlWindows, _
    StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(8, _
    9), Array(41, 9), Array(51, 9), Array(59, 1), Array(65, 9))

    Rows("1:1").Insert Shift:=xlDown


    When the code gets to the second line, it inserts a line at the top of the sheet containing the macro, not in the file I've just opened.

    I even tried putting in a line to activate the right workbook, which it did, but still inserted the row in the other sheet.

    It still works perfectly when I run it from personal.xls.

    Any ideas?

    Thanks

    Colin

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    The line of code Rows("1:1").Insert Shift:=xlDown will insert the row into which ever sheet is active

    Did you try to activate the sheet or just the book - You may need to activate both of them

    Another option is

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-10-2004
    MS-Off Ver
    Office 2003
    Posts
    70
    Thanks Mudraker, that worked fine.

    Just never come across that problem before.

    Colin

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Good to hear your problem is fixed & thanks for the feed back

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1