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

Private Sub Worksheet_Activate()
Dim i As Integer
Dim rCell As Range
Application.ScreenUpdating = False
Set rCell = Worksheets("Paydata Import File Sample").Range("D1")
Do
If rCell.Value = rCell.Offset(-1, 0).Value Then
i = i + 1
End If
Set rCell = rCell.Offset(1, 0)
Loop Until rCell.Value = ""
Sheets("Statistics").Range("C1").Value = i
Application.ScreenUpdating = True
End Sub

HTH
--
AP

"Lp12" a écrit dans le message de news:
...

Hi Norman,
Thanks for you answer.
How exaclty can i avaoid selection? can you give me an example?
Thanks a lot
"Norman Jones" wrote:

Hi Lp12,

Without otherwise looking at your code, selections can only be made on
the
active sheet.

Therefore, either activate the required sheet or, preferably, rewrite
your
code to avoid selections.


---
Regards,
Norman



"Lp12" wrote in message
...
Hi All i get the 1004 error msg when the code enters:
Worksheets("Paydata
Import File Sample").Range("D1").Select
Im using excel2003.
I've tried to see other threads but in vain.
Any thoughts?


Private Sub Worksheet_Activate()
Dim i As Integer
Application.ScreenUpdating = False
Worksheets("Paydata Import File Sample").Range("D1").Select
Do
If ActiveCell.Value = ActiveCell.Offset(-1, 0).Value Then
i = i + 1
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Value = ""
Sheets("Statistics").Select
Range("C1").Value = i
Application.ScreenUpdating = True
End Sub






 
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
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 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


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