+ Reply to Thread
Results 1 to 5 of 5

Delete a Row

  1. #1
    Ken Hudson
    Guest

    Delete a Row

    I want to delete a row in a different, open workbook, but can't get the
    syntax right.

    Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete

    doesn't work.
    --
    Ken Hudson

  2. #2
    Norman Jones
    Guest

    Re: Delete a Row

    Hi Ken,

    Your syntax works for me.

    I tested using:

    '=============>>
    Public Sub Tester()
    Const TestBookName As String = "Book2.xls"
    Const RowNumber As Long = 2

    Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete

    End Sub
    '<<=============


    ---
    Regards,
    Norman



    "Ken Hudson" <[email protected]> wrote in message
    news:[email protected]...
    >I want to delete a row in a different, open workbook, but can't get the
    > syntax right.
    >
    > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    >
    > doesn't work.
    > --
    > Ken Hudson




  3. #3
    Toppers
    Guest

    Re: Delete a Row

    Hi,
    In XL2003 only works if TestBookName="Book2" not "Book2.xls" (or at
    least on my m/c!)

    "Norman Jones" wrote:

    > Hi Ken,
    >
    > Your syntax works for me.
    >
    > I tested using:
    >
    > '=============>>
    > Public Sub Tester()
    > Const TestBookName As String = "Book2.xls"
    > Const RowNumber As Long = 2
    >
    > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    >
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Ken Hudson" <[email protected]> wrote in message
    > news:[email protected]...
    > >I want to delete a row in a different, open workbook, but can't get the
    > > syntax right.
    > >
    > > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    > >
    > > doesn't work.
    > > --
    > > Ken Hudson

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Delete a Row

    It would depend on whether the workbook was named Book2 (an unsaved
    workbook) or Book2.xls. I suspect Norman was either using a saved workbook
    or emphasizing the valuable lesson that if a workbook has been saved, then
    it should be addressed in the workbooks collection with the extension
    included.

    On computers with the Windows setting of Hide Known extensions, then
    Workbook("Book2") could be used to refer to Book2.xls.

    --
    Regards,
    Tom Ogilvy

    "Toppers" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > In XL2003 only works if TestBookName="Book2" not "Book2.xls" (or

    at
    > least on my m/c!)
    >
    > "Norman Jones" wrote:
    >
    > > Hi Ken,
    > >
    > > Your syntax works for me.
    > >
    > > I tested using:
    > >
    > > '=============>>
    > > Public Sub Tester()
    > > Const TestBookName As String = "Book2.xls"
    > > Const RowNumber As Long = 2
    > >
    > > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    > >
    > > End Sub
    > > '<<=============
    > >
    > >
    > > ---
    > > Regards,
    > > Norman
    > >
    > >
    > >
    > > "Ken Hudson" <[email protected]> wrote in message
    > > news:[email protected]...
    > > >I want to delete a row in a different, open workbook, but can't get the
    > > > syntax right.
    > > >
    > > > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    > > >
    > > > doesn't work.
    > > > --
    > > > Ken Hudson

    > >
    > >
    > >




  5. #5
    Toppers
    Guest

    Re: Delete a Row

    Tom,
    Yet another lesson! My workbook had not been saved and hence my
    result. So much to remember - my age is definitely working against me.

    Thanks again.

    "Tom Ogilvy" wrote:

    > It would depend on whether the workbook was named Book2 (an unsaved
    > workbook) or Book2.xls. I suspect Norman was either using a saved workbook
    > or emphasizing the valuable lesson that if a workbook has been saved, then
    > it should be addressed in the workbooks collection with the extension
    > included.
    >
    > On computers with the Windows setting of Hide Known extensions, then
    > Workbook("Book2") could be used to refer to Book2.xls.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Toppers" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > > In XL2003 only works if TestBookName="Book2" not "Book2.xls" (or

    > at
    > > least on my m/c!)
    > >
    > > "Norman Jones" wrote:
    > >
    > > > Hi Ken,
    > > >
    > > > Your syntax works for me.
    > > >
    > > > I tested using:
    > > >
    > > > '=============>>
    > > > Public Sub Tester()
    > > > Const TestBookName As String = "Book2.xls"
    > > > Const RowNumber As Long = 2
    > > >
    > > > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    > > >
    > > > End Sub
    > > > '<<=============
    > > >
    > > >
    > > > ---
    > > > Regards,
    > > > Norman
    > > >
    > > >
    > > >
    > > > "Ken Hudson" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > >I want to delete a row in a different, open workbook, but can't get the
    > > > > syntax right.
    > > > >
    > > > > Workbooks(TestBookName).Sheets(1).Rows(RowNumber).Delete
    > > > >
    > > > > doesn't work.
    > > > > --
    > > > > Ken Hudson
    > > >
    > > >
    > > >

    >
    >
    >


+ 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