View Single Post
  #18   Report Post  
Posted to microsoft.public.excel.newusers
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default excel same value in two cells

That seems cool...........thanks Gord.

Vaya con Dios,
Chuck, CABGx3



"Gord Dibben" wrote:

Chuck

If you're going to start disabling events you should trap for errors so you
re-enable if the code errors.

On Error Goto stoppit
Application.EnableEvents = False

'code here

stoppit:
Application.EnableEvents = True


Gord

On Thu, 26 Jul 2007 10:16:08 -0700, CLR wrote:

Actually, in some "circles", 198 "Chuck's" might be condsidered more
desirable than just one.........I love my mirror)..... <G

Vaya con Dios,
Chuck, CABGx3




"Gord Dibben" wrote:

Pete

I tested on a new workbook with nothing in it and received the multiple Chuck's
as Sandy did. 198 to be exact.

One Chuck with events disabled.


Gord

On Thu, 26 Jul 2007 09:30:27 -0700, Pete_UK wrote:

Hi Sandy,

I'm certainly no expert in VBA, but could you possibly have a NOW()
function somewhere on the sheet or something similar, which is causing
it to recalculate (and therefore change) to trigger the macro?

Just a thought ...

Pete

On Jul 26, 4:37 pm, "Sandy Mann" wrote:
Hi Chuck,

It was Chip that pointed out to me some time ago that one of my codes was
multi-firing because I missed those lines off although I could not see
anything happening on the sheet.

The code I used was:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Debug.Print "Chuck"
'Application.EnableEvents = False
If Target.Address = "$A$1" Then
Range("a2").Value = Range("a1").Value
Else
If Target.Address = "$A$2" Then
Range("a1").Value = Range("a2").Value
Else
End If
End If
'Application.EnableEvents = True
End Sub

Then I copied the entries in the Immediate Window and pasted them into a
sheet using Paste Special Unicode Text to find that I had 198 Rows of
"Chuck"

What puzzles me is if, with the entries still in the Immediate Window, I
change the Debug.Print line to "Chuck2" I only get 65 "Chuck2". If I then
clear all the entries in the Immediate Window and run the code again I am
back to having 198 entries! Perhaps one of the real experts can explain that
to us.

If you un-comment the EnableEvents lines that you will only get one "Chuck"

--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk

"CLR" wrote in message

...



Hi Sandy.........
I bow to your much greater experience, and wish to learn all I can. In
this
instance, I intentionally left those lines off and do so as a general rule
anymore because I like to see things flash as the macro
progresses.....sort
of in lieu of a progress indicator. I was not aware that their absence
could
actually affect the operation of the macro itself. I use '97 also, and
see
no evidence of multiple firings here. How did you conclude that the macro
had fired 198 times?

Vaya con Dios,
Chuck, CABGx3- Hide quoted text -

- Show quoted text -