+ Reply to Thread
Results 1 to 2 of 2

Run time error 1004 - what have I done wrong?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2006
    Posts
    12

    Run time error 1004 - what have I done wrong?

    Anybody know why this is a problem?

        Sheets("data").Select
        h = UsedRange.Rows.Count
        Rows("2:" & h).Select
        Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("H2") _
           , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
         False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
        :=xlSortNormal
    Alex

  2. #2
    Chip Pearson
    Guest

    Re: Run time error 1004 - what have I done wrong?

    You need to change
    h = UsedRange.Rows.Count
    to
    h = ActiveSheet.UsedRange.Rows.Count



    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "alexwren"
    <alexwren.2birut_1153861808.4225@excelforum-nospam.com> wrote in
    message
    news:alexwren.2birut_1153861808.4225@excelforum-nospam.com...
    >
    > Anybody know why this is a problem?
    >
    >
    > Code:
    > --------------------
    > Sheets("data").Select
    > h = UsedRange.Rows.Count
    > Rows("2:" & h).Select
    > Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
    > Key2:=Range("H2") _
    > , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
    > MatchCase:= _
    > False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
    > DataOption2 _
    > :=xlSortNormal
    > --------------------
    >
    >
    > Alex
    >
    >
    > --
    > alexwren
    > ------------------------------------------------------------------------
    > alexwren's Profile:
    > http://www.excelforum.com/member.php...o&userid=36767
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=564910
    >




+ 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