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
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
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
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
>
>
>
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
> >
> >
> >
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
> > >
> > >
> > >
>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks