View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.newusers
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default excel same value in two cells

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 -