Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Run-time error: '9'

This code is giving me a Run-time error: '9' Subscript out of range:

Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

Per some previous advice I added the file type to "Test Tally SheetII.xlsm"
Since I'm working in 07 and my sheet is saved as .xlsm I used that instead of
..xls. But it locks up on this line still.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Run-time error: '9'

This is to do with the workbook name only..Please check for spaces...OR in
immediate window type ?Activeworkbook.name and copy paste..

If it is the activeworkbook you can try the below



Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Activeworkbook.Sheets("Catalyst Dump").Cells(Rows.Count,
"A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

This code is giving me a Run-time error: '9' Subscript out of range:

Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

Per some previous advice I added the file type to "Test Tally SheetII.xlsm"
Since I'm working in 07 and my sheet is saved as .xlsm I used that instead of
.xls. But it locks up on this line still.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Run-time error: '9'

First, there are two logical lines in your posted code that could cause the
error.

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row


This error means that either you don't have a workbook named
"test tally sheetii.xlsm" open.

Or that you have a workbook open with that name, but it doesn't contain a
worksheet named "catalyst dump"

If it locks up on that last line

Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13


then the activeworkbook doesn't have a worksheet named "catalyst dump".

You could qualify that worksheet like you did in top line:

Workbooks("Test Tally SheetII.xlsm").Worksheets("Catalyst Dump") _

.Columns("D").ColumnWidth = 13

Bishop wrote:

This code is giving me a Run-time error: '9' Subscript out of range:

Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

Per some previous advice I added the file type to "Test Tally SheetII.xlsm"
Since I'm working in 07 and my sheet is saved as .xlsm I used that instead of
.xls. But it locks up on this line still.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Run-time error: '9'

And also check for the exact sheet name "Catalyst Dump" (with no spaces)

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

This is to do with the workbook name only..Please check for spaces...OR in
immediate window type ?Activeworkbook.name and copy paste..

If it is the activeworkbook you can try the below



Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Activeworkbook.Sheets("Catalyst Dump").Cells(Rows.Count,
"A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

This code is giving me a Run-time error: '9' Subscript out of range:

Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

Per some previous advice I added the file type to "Test Tally SheetII.xlsm"
Since I'm working in 07 and my sheet is saved as .xlsm I used that instead of
.xls. But it locks up on this line still.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Run-time error: '9'

Ok, your "?Activeworkbook.name" in the Immediate Window trick gave me this:
Test Tally SheetII.xls
So I changed the file type from .xlsm to .xls and that worked. BUT it only
works if that is the active workbook. I'm trying to make this code work no
matter what sheet is active. Now I'm getting '1004' again.

"Jacob Skaria" wrote:

This is to do with the workbook name only..Please check for spaces...OR in
immediate window type ?Activeworkbook.name and copy paste..

If it is the activeworkbook you can try the below



Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Activeworkbook.Sheets("Catalyst Dump").Cells(Rows.Count,
"A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

This code is giving me a Run-time error: '9' Subscript out of range:

Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

Per some previous advice I added the file type to "Test Tally SheetII.xlsm"
Since I'm working in 07 and my sheet is saved as .xlsm I used that instead of
.xls. But it locks up on this line still.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Run-time error: '9'

Ok, so I added the following line:
Workbooks("Test Tally SheetII.xls").Activate

And now it works as expected. Thanks for you help. You've answered several
of my questions and your advise is always solid.

"Bishop" wrote:

Ok, your "?Activeworkbook.name" in the Immediate Window trick gave me this:
Test Tally SheetII.xls
So I changed the file type from .xlsm to .xls and that worked. BUT it only
works if that is the active workbook. I'm trying to make this code work no
matter what sheet is active. Now I'm getting '1004' again.

"Jacob Skaria" wrote:

This is to do with the workbook name only..Please check for spaces...OR in
immediate window type ?Activeworkbook.name and copy paste..

If it is the activeworkbook you can try the below



Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Activeworkbook.Sheets("Catalyst Dump").Cells(Rows.Count,
"A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

This code is giving me a Run-time error: '9' Subscript out of range:

Dim CDLastRow As Long 'Catalyst Dump
Dim EDLastRow As Long 'Exported Data

CDLastRow = Workbooks("Test Tally SheetII.xlsm").Worksheets _
("Catalyst Dump").Cells(Rows.Count, "A").End(xlUp).Row
Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 13

Per some previous advice I added the file type to "Test Tally SheetII.xlsm"
Since I'm working in 07 and my sheet is saved as .xlsm I used that instead of
.xls. But it locks up on this line still.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Urgent!!! Run-time error '-2147024770 (8007007e)' Automation error [email protected] Excel Programming 3 May 28th 08 04:51 AM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 11:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"