Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Macro Crashing

My macro keeps crashing. Here is the error message and applicabe code:

Subscript out of range in
Project1.Form1.FormatSpread at line 6960

6960 ActiveWorkbook.Worksheets("BaseBid").Activate
Range("C35").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 = "=Labor!R[-34]C[3]"
ActiveSheet.Protect Password:="Rj6823Lkt2"


ActiveWorkbook.Worksheets("JobCost").Activate
Range("D88").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 =
"=(SUMIF(Labor!R3C2:R499C2,RC[-3],Labor!R3C6:R499C6))*.75+SUMIF(Worksheet!R4C5:R173 C5,RC[-3],Worksheet!R4C1:R173C1)+SUMIF(BaseBid!R34C2:R77C2, RC[-3],BaseBid!R34C7:R77C7)"
Selection.AutoFill Destination:=Range("D88:D242"),
Type:=xlFillDefault
Range("A9").Select
Range("A7").Select
ActiveSheet.Protect Password:="Rj6823Lkt2"

Any help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Macro Crashing

Hi

The error message indicate that the sheet doesn't exist in the active
workbook, or it may be due to a typo.

As you use the same password through out your code, I would use a variable
to hold the password, then you also decrease the risk for a typo:

Dim MyPassWd As String
MyPassWd = "Rj6823Lkt2"
Worksheets("BaseBid").Unprotect Password:=MyPassWd

ActiveSheet.Unprotect MyPassWd
Range("C35").FormulaR1C1 = "=Labor!R[-34]C[3]"
ActiveSheet.Protect Password:=MyPassWd

Worksheets("JobCost").Activate
ActiveSheet.Unprotect MyPassWd
Range("D88").FormulaR1C1 = _
"=(SUMIF(Labor!R3C2:R499C2,RC[-3],Labor!R3C6:R499C6))*.75+SUMIF(Worksheet!R4C5:R173 C5,RC[-3],Worksheet!R4C1:R173C1)+SUMIF(BaseBid!R34C2:R77C2, RC[-3],BaseBid!R34C7:R77C7)"
Range("D88").AutoFill Destination:=Range("D88:D242"), Type:=xlFillDefault
ActiveSheet.Protect Password:=MyPassWd

Regards,
Per

"mickey" skrev i meddelelsen
...
My macro keeps crashing. Here is the error message and applicabe code:

Subscript out of range in
Project1.Form1.FormatSpread at line 6960

6960 ActiveWorkbook.Worksheets("BaseBid").Activate
Range("C35").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 = "=Labor!R[-34]C[3]"
ActiveSheet.Protect Password:="Rj6823Lkt2"


ActiveWorkbook.Worksheets("JobCost").Activate
Range("D88").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 =
"=(SUMIF(Labor!R3C2:R499C2,RC[-3],Labor!R3C6:R499C6))*.75+SUMIF(Worksheet!R4C5:R173 C5,RC[-3],Worksheet!R4C1:R173C1)+SUMIF(BaseBid!R34C2:R77C2, RC[-3],BaseBid!R34C7:R77C7)"
Selection.AutoFill Destination:=Range("D88:D242"),
Type:=xlFillDefault
Range("A9").Select
Range("A7").Select
ActiveSheet.Protect Password:="Rj6823Lkt2"

Any help?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Macro Crashing

Thanks. That's great info on the password.
The sheet does exist. So, it probably is a typo, I just can't figure out
where it is.

"Per Jessen" wrote:

Hi

The error message indicate that the sheet doesn't exist in the active
workbook, or it may be due to a typo.

As you use the same password through out your code, I would use a variable
to hold the password, then you also decrease the risk for a typo:

Dim MyPassWd As String
MyPassWd = "Rj6823Lkt2"
Worksheets("BaseBid").Unprotect Password:=MyPassWd

ActiveSheet.Unprotect MyPassWd
Range("C35").FormulaR1C1 = "=Labor!R[-34]C[3]"
ActiveSheet.Protect Password:=MyPassWd

Worksheets("JobCost").Activate
ActiveSheet.Unprotect MyPassWd
Range("D88").FormulaR1C1 = _
"=(SUMIF(Labor!R3C2:R499C2,RC[-3],Labor!R3C6:R499C6))*.75+SUMIF(Worksheet!R4C5:R173 C5,RC[-3],Worksheet!R4C1:R173C1)+SUMIF(BaseBid!R34C2:R77C2, RC[-3],BaseBid!R34C7:R77C7)"
Range("D88").AutoFill Destination:=Range("D88:D242"), Type:=xlFillDefault
ActiveSheet.Protect Password:=MyPassWd

Regards,
Per

"mickey" skrev i meddelelsen
...
My macro keeps crashing. Here is the error message and applicabe code:

Subscript out of range in
Project1.Form1.FormatSpread at line 6960

6960 ActiveWorkbook.Worksheets("BaseBid").Activate
Range("C35").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 = "=Labor!R[-34]C[3]"
ActiveSheet.Protect Password:="Rj6823Lkt2"


ActiveWorkbook.Worksheets("JobCost").Activate
Range("D88").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 =
"=(SUMIF(Labor!R3C2:R499C2,RC[-3],Labor!R3C6:R499C6))*.75+SUMIF(Worksheet!R4C5:R173 C5,RC[-3],Worksheet!R4C1:R173C1)+SUMIF(BaseBid!R34C2:R77C2, RC[-3],BaseBid!R34C7:R77C7)"
Selection.AutoFill Destination:=Range("D88:D242"),
Type:=xlFillDefault
Range("A9").Select
Range("A7").Select
ActiveSheet.Protect Password:="Rj6823Lkt2"

Any help?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Macro Crashing

The first thing to test is whether the ActiveWorkbook (the workbook
open in Excel, which may not be the same workbook that contains the
code) does indeed have a sheet named "BaseBid". Ensure that you don't
have any spaces before, within, or after the worksheet name.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Thu, 19 Mar 2009 11:36:06 -0700, mickey
wrote:

My macro keeps crashing. Here is the error message and applicabe code:

Subscript out of range in
Project1.Form1.FormatSpread at line 6960

6960 ActiveWorkbook.Worksheets("BaseBid").Activate
Range("C35").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 = "=Labor!R[-34]C[3]"
ActiveSheet.Protect Password:="Rj6823Lkt2"


ActiveWorkbook.Worksheets("JobCost").Activate
Range("D88").Select
ActiveSheet.Unprotect "Rj6823Lkt2"
ActiveCell.FormulaR1C1 =
"=(SUMIF(Labor!R3C2:R499C2,RC[-3],Labor!R3C6:R499C6))*.75+SUMIF(Worksheet!R4C5:R173 C5,RC[-3],Worksheet!R4C1:R173C1)+SUMIF(BaseBid!R34C2:R77C2, RC[-3],BaseBid!R34C7:R77C7)"
Selection.AutoFill Destination:=Range("D88:D242"),
Type:=xlFillDefault
Range("A9").Select
Range("A7").Select
ActiveSheet.Protect Password:="Rj6823Lkt2"

Any help?

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
How do I prevent an error from crashing my macro? Don M. Excel Programming 4 March 11th 08 04:58 PM
Crashing Macro, Not Enough Memory [email protected] Excel Programming 2 October 7th 05 11:11 AM
Help with a crashing Macro needed Tadragh1 Excel Programming 6 August 13th 05 10:46 PM
Macro crashing on different computer Grace[_3_] Excel Programming 8 July 8th 04 04:12 AM
Macro Crashing Excel ultra_xcyter[_3_] Excel Programming 0 June 28th 04 02:56 PM


All times are GMT +1. The time now is 10:00 AM.

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

About Us

"It's about Microsoft Excel"