+ Reply to Thread
Results 1 to 6 of 6

Confused, help with this line please!

  1. #1
    serdar
    Guest

    Confused, help with this line please!

    Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp

    works fine, but

    Worksheets(3).Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp

    gives a runtime error 1004 message.

    why? ( function is in worksheet 1 )



  2. #2
    Don Guillett
    Guest

    Re: Confused, help with this line please!

    try it this way
    Sheets(3).Range("a9:f9").Delete Shift:=xlUp

    Don Guillett
    SalesAid Software
    [email protected]
    "serdar" <[email protected]> wrote in message
    news:[email protected]...
    > Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >
    > works fine, but
    >
    > Worksheets(3).Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >
    > gives a runtime error 1004 message.
    >
    > why? ( function is in worksheet 1 )
    >
    >




  3. #3
    serdar
    Guest

    Re: Confused, help with this line please!

    i need to use variables instead of "a9:f9" but this helped me, thanks:

    http://www.xtremevbtalk.com/archive/.../t-225724.html






    "Don Guillett" <[email protected]>, haber iletisinde şunları
    yazdı:[email protected]...
    > try it this way
    > Sheets(3).Range("a9:f9").Delete Shift:=xlUp
    >
    > Don Guillett
    > SalesAid Software
    > [email protected]




  4. #4
    serdar
    Guest

    Re: Confused, help with this line please!

    Checked forums on the net. This works.

    Worksheets(3).Range(Worksheets(3).Cells(9, 1), Worksheets(3).Cells(9,
    6)).Delete Shift:=xlUp


    "serdar" <[email protected]>, haber iletisinde şunları
    yazdı:[email protected]...
    > Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >
    > works fine, but
    >
    > Worksheets(3).Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >
    > gives a runtime error 1004 message.
    >
    > why? ( function is in worksheet 1 )
    >
    >




  5. #5
    Chip Pearson
    Guest

    Re: Confused, help with this line please!

    The reason is that the you have the code in the Sheet(1) code
    module. Thus, the Cells references refer to the cells on Sheet1,
    while you are attempting to create a range on Sheet(3). A range
    cannot span more than one worksheet. Instead, try

    With Worksheets(3)
    .Range(.Cells(9,1),.Cells(9,6)).Delete shift:=xlUp
    End With

    Note the leading periods in 'Range' and 'Cells'.


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






    "serdar" <[email protected]> wrote in message
    news:[email protected]...
    > Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >
    > works fine, but
    >
    > Worksheets(3).Range(Cells(9, 1), Cells(9, 6)).Delete
    > Shift:=xlUp
    >
    > gives a runtime error 1004 message.
    >
    > why? ( function is in worksheet 1 )
    >
    >




  6. #6
    Alan Beban
    Guest

    Re: Confused, help with this line please!

    So will

    Set rng = Worksheets(3).Range("A1")
    Range(rng(9,1),rng(9,6)).Delete Shift:=xlUp

    not tested
    Alan Beban

    serdar wrote:
    > Checked forums on the net. This works.
    >
    > Worksheets(3).Range(Worksheets(3).Cells(9, 1), Worksheets(3).Cells(9,
    > 6)).Delete Shift:=xlUp
    >
    >
    > "serdar" <[email protected]>, haber iletisinde şunları
    > yazdı:[email protected]...
    >
    >>Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >>
    >>works fine, but
    >>
    >>Worksheets(3).Range(Cells(9, 1), Cells(9, 6)).Delete Shift:=xlUp
    >>
    >>gives a runtime error 1004 message.
    >>
    >>why? ( function is in worksheet 1 )
    >>
    >>

    >
    >
    >


+ 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