LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default error 1004?

The only time I get that error is when the sheet is still protected. However
if the password you have supplied is incorrect then the error should occur on
the unprotect line.

Also you should probably disable events here so that you don't get into a
loop. Do you want to make C6 the only cell which can be active on the sheet?
This is currently the case.

Finally, are you sure this is the formula you are wanting to place is C6:
=SUM(C7,1)

Maybe your event should look like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo ErrorHandler
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="peterke"
Range("C6").FormulaR1C1 = "=SUM(R[1]C,1)" 'supply correct formula
ActiveSheet.Protect Password:="peterke"

ErrorHandler:
Application.EnableEvents = True
End Sub

Hope this helps
Rowan

"Peterke" wrote:

Hi,

Why does the error 1004 occure here?
(error marked between <<)
and what do I do to avoid it in the future?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect Password:="peterke"
Application.ScreenUpdating = False
Range("C6").Select
ActiveCell.FormulaR1C1 = "=SUM(R[1]C,1)"<<

Range("C6").Select
ActiveSheet.Protect Password:="peterke"
Application.ScreenUpdating = True
End Sub


greets,
Peterke



 
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 [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Interior class error/runtime error 1004 David Goodall Excel Programming 1 October 24th 04 10:16 PM


All times are GMT +1. The time now is 08:02 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"