ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   1004 error (https://www.excelbanter.com/excel-programming/362984-1004-error.html)

Lp12

1004 error
 
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


Norman Jones

1004 error
 
Hi Lp12,

My apologies - I had inadvertently changed my date setting!


---
Regards,
Norman



Lp12

1004 error
 

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





Ardus Petus

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








All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com