Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Run Time Error 1004: Application or Object Defined Error

Error shows up in second code.
I've tried all kinds of ways of stating but end up with this error every time.


Option Explicit
Private Sub REmove_Net_Pricing_Info_Click()
' SelectButton Macro

Sheets("Options").Range("OptionsPgPricing").ClearC ontents
Sheets("Pricing").Range("PricePgPricing").ClearCon tents
Sheets("Contract").Activate
Range("B1").Select
End Sub

Private Sub Replace_Deleted_Click()

' Run Time Error 1004: Application Defined or Object Defined Error
Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"

Sheets("Pricing").Range("C128").Select
ActiveCell.FormulaR1C1 = "=Round(G128,0)"

' Replace Link on Options Sheet
Sheets("Options").Range("H6").Select
ActiveCell.FormulaR1C1 = "=Pricing!$C$128"

' Place curson on Contract, Cell B1
Sheets("Contract").Range("B1").Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run Time Error 1004: Application or Object Defined Error

If you intend to select a range on a sheet then you first need to select the
sheet something like this...

Sheets("Pricing").Select
Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"

or you could avoid the selects all together like this...

Sheets("Pricing").Range("C127").Value = "CUSTOMER SPECIAL CONTRACT PRICE"

--
HTH...

Jim Thomlinson


"BEEJAY" wrote:

Error shows up in second code.
I've tried all kinds of ways of stating but end up with this error every time.


Option Explicit
Private Sub REmove_Net_Pricing_Info_Click()
' SelectButton Macro

Sheets("Options").Range("OptionsPgPricing").ClearC ontents
Sheets("Pricing").Range("PricePgPricing").ClearCon tents
Sheets("Contract").Activate
Range("B1").Select
End Sub

Private Sub Replace_Deleted_Click()

' Run Time Error 1004: Application Defined or Object Defined Error
Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"

Sheets("Pricing").Range("C128").Select
ActiveCell.FormulaR1C1 = "=Round(G128,0)"

' Replace Link on Options Sheet
Sheets("Options").Range("H6").Select
ActiveCell.FormulaR1C1 = "=Pricing!$C$128"

' Place curson on Contract, Cell B1
Sheets("Contract").Range("B1").Select
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Run Time Error 1004: Application or Object Defined Error

2 things I would do

1) Make sure the TakeFocusOnClick property of the button(s) is set to false
2) Don't select and then work with activecell as you will not be able to
select cells on a non-activesheet, so...

Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"


Becomes...

Sheets("Pricing").Range("C127").Value = "CUSTOMER SPECIAL CONTRACT PRICE"

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

HIS
www.nickhodge.co.uk

"BEEJAY" wrote in message
...
Error shows up in second code.
I've tried all kinds of ways of stating but end up with this error every
time.


Option Explicit
Private Sub REmove_Net_Pricing_Info_Click()
' SelectButton Macro

Sheets("Options").Range("OptionsPgPricing").ClearC ontents
Sheets("Pricing").Range("PricePgPricing").ClearCon tents
Sheets("Contract").Activate
Range("B1").Select
End Sub

Private Sub Replace_Deleted_Click()

' Run Time Error 1004: Application Defined or Object Defined Error
Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"

Sheets("Pricing").Range("C128").Select
ActiveCell.FormulaR1C1 = "=Round(G128,0)"

' Replace Link on Options Sheet
Sheets("Options").Range("H6").Select
ActiveCell.FormulaR1C1 = "=Pricing!$C$128"

' Place curson on Contract, Cell B1
Sheets("Contract").Range("B1").Select
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Run Time Error 1004: Application or Object Defined Error

Gentlemen: Thanks much. I used the 'non-select' examples - No problems.

Questions/Comments:
1: Jim: I had tried your first suggestion, with no success.
It would work for statement 1 and 2, then error on statement 3.

2: "Before selecting a range, make sure you've ACTIVATED (emphasise mine)
the ranges worksheet" (J.Walk Excel VBA Programming for Dummies).
So, changed the first line to ACTIVATE instead of Select.
Still the same error problem.
Is there a beginners level explanation for this?

ALSO:
As I understand it:
Activate: The equivalent of selecting the tab for that sheet.
Select: Do something to that (range on) that sheet, even though it
is not the current active (opened) Sheet.
Am I close?
Is there a good (Excel) dictionary available somewhere on the internet that
would
be suitable for 'dummies' like me?

Thanks again. I get a wealth of information and knowledge from this
newsgroup.
This keeps me keep on trying.

"Nick Hodge" wrote:

2 things I would do

1) Make sure the TakeFocusOnClick property of the button(s) is set to false
2) Don't select and then work with activecell as you will not be able to
select cells on a non-activesheet, so...

Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"


Becomes...

Sheets("Pricing").Range("C127").Value = "CUSTOMER SPECIAL CONTRACT PRICE"

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

HIS
www.nickhodge.co.uk

"BEEJAY" wrote in message
...
Error shows up in second code.
I've tried all kinds of ways of stating but end up with this error every
time.


Option Explicit
Private Sub REmove_Net_Pricing_Info_Click()
' SelectButton Macro

Sheets("Options").Range("OptionsPgPricing").ClearC ontents
Sheets("Pricing").Range("PricePgPricing").ClearCon tents
Sheets("Contract").Activate
Range("B1").Select
End Sub

Private Sub Replace_Deleted_Click()

' Run Time Error 1004: Application Defined or Object Defined Error
Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"

Sheets("Pricing").Range("C128").Select
ActiveCell.FormulaR1C1 = "=Round(G128,0)"

' Replace Link on Options Sheet
Sheets("Options").Range("H6").Select
ActiveCell.FormulaR1C1 = "=Pricing!$C$128"

' Place curson on Contract, Cell B1
Sheets("Contract").Range("B1").Select
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run Time Error 1004: Application or Object Defined Error

Try this...
Sheets("Pricing").Select
Range("C127").Select
ActiveCell.Value = "CUSTOMER SPECIAL CONTRACT PRICE"

--
HTH...

Jim Thomlinson


"BEEJAY" wrote:

Gentlemen: Thanks much. I used the 'non-select' examples - No problems.

Questions/Comments:
1: Jim: I had tried your first suggestion, with no success.
It would work for statement 1 and 2, then error on statement 3.

2: "Before selecting a range, make sure you've ACTIVATED (emphasise mine)
the ranges worksheet" (J.Walk Excel VBA Programming for Dummies).
So, changed the first line to ACTIVATE instead of Select.
Still the same error problem.
Is there a beginners level explanation for this?

ALSO:
As I understand it:
Activate: The equivalent of selecting the tab for that sheet.
Select: Do something to that (range on) that sheet, even though it
is not the current active (opened) Sheet.
Am I close?
Is there a good (Excel) dictionary available somewhere on the internet that
would
be suitable for 'dummies' like me?

Thanks again. I get a wealth of information and knowledge from this
newsgroup.
This keeps me keep on trying.

"Nick Hodge" wrote:

2 things I would do

1) Make sure the TakeFocusOnClick property of the button(s) is set to false
2) Don't select and then work with activecell as you will not be able to
select cells on a non-activesheet, so...

Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"


Becomes...

Sheets("Pricing").Range("C127").Value = "CUSTOMER SPECIAL CONTRACT PRICE"

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

HIS
www.nickhodge.co.uk

"BEEJAY" wrote in message
...
Error shows up in second code.
I've tried all kinds of ways of stating but end up with this error every
time.


Option Explicit
Private Sub REmove_Net_Pricing_Info_Click()
' SelectButton Macro

Sheets("Options").Range("OptionsPgPricing").ClearC ontents
Sheets("Pricing").Range("PricePgPricing").ClearCon tents
Sheets("Contract").Activate
Range("B1").Select
End Sub

Private Sub Replace_Deleted_Click()

' Run Time Error 1004: Application Defined or Object Defined Error
Sheets("Pricing").Range("C127").Select
ActiveCell.FormulaR1C1 = "CUSTOMER SPECIAL CONTRACT PRICE"

Sheets("Pricing").Range("C128").Select
ActiveCell.FormulaR1C1 = "=Round(G128,0)"

' Replace Link on Options Sheet
Sheets("Options").Range("H6").Select
ActiveCell.FormulaR1C1 = "=Pricing!$C$128"

' Place curson on Contract, Cell B1
Sheets("Contract").Range("B1").Select
End Sub







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 - Application-defined or object-defined error brent Excel Programming 2 October 3rd 05 05:23 PM
Run-time Error 1004: Application-defined or Object-defined Error Adrian Excel Programming 6 August 23rd 05 06:28 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


All times are GMT +1. The time now is 03:19 AM.

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"