Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default excel same value in two cells

How can 2 cells have the same values, such that when I edit either cell the
change is reflected on both?
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 13
Default excel same value in two cells

It is not possible without using some sophisticated features of event
listening and macros. But one should ask the question: what would be the
benefits? You can refer the second cell from the first one -- something like
A2: =A1, so A1 and A2 will both have the same value and each time you change
A1, A2 will change.

pls help wrote:
How can 2 cells have the same values, such that when I edit either cell the
change is reflected on both?


  #3   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

This macro will do as you describe.........

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
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
End Sub

Vaya con Dios,
Chuck, CABGx3



"pls help" wrote:

How can 2 cells have the same values, such that when I edit either cell the
change is reflected on both?

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 13
Default excel same value in two cells

On my version of Excel 2003, if I am in A1 and type 444 then press the down
arrow, A1 is being updated with the value from A2...

I would recommend that you replace the first line:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
by:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

  #5   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

Interesting.....good catch.
Thanks for the heads-up.

Vaya con Dios,
Chuck, CABGx3



"squenson" wrote:

On my version of Excel 2003, if I am in A1 and type 444 then press the down
arrow, A1 is being updated with the value from A2...

I would recommend that you replace the first line:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
by:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)




  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,345
Default excel same value in two cells

Chuck,

You will also have to have a line:

Application.EnableEvents = False

before any changes are made to the sheet and:

Application.EnableEvents = True

before the End Sub to stop the code firing multiple times. For me in XL97
it fires 198 time before VBA thows in the towel.

--
HTH

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
...
Interesting.....good catch.
Thanks for the heads-up.

Vaya con Dios,
Chuck, CABGx3



"squenson" wrote:

On my version of Excel 2003, if I am in A1 and type 444 then press the
down
arrow, A1 is being updated with the value from A2...

I would recommend that you replace the first line:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
by:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)





  #7   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

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


"Sandy Mann" wrote:

Chuck,

You will also have to have a line:

Application.EnableEvents = False

before any changes are made to the sheet and:

Application.EnableEvents = True

before the End Sub to stop the code firing multiple times. For me in XL97
it fires 198 time before VBA thows in the towel.

--
HTH

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
...
Interesting.....good catch.
Thanks for the heads-up.

Vaya con Dios,
Chuck, CABGx3



"squenson" wrote:

On my version of Excel 2003, if I am in A1 and type 444 then press the
down
arrow, A1 is being updated with the value from A2...

I would recommend that you replace the first line:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
by:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)






Reply
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
Excel: match two cells in one sheet to two cells in another and return a third cells value Spence Excel Worksheet Functions 3 February 13th 11 05:33 AM
Excel-only average cells if two cells in same row, meet two condit Eulie-Denver Excel Worksheet Functions 5 October 5th 06 11:15 PM
conditional formating cells i Excel based on other cells values Elias Petursson Excel Worksheet Functions 3 May 23rd 06 06:45 PM
Excel inserted 0's in cells linked to blank cells lburg801 Excel Discussion (Misc queries) 5 October 28th 05 11:32 PM
Pasting single cells from Word to multiple cells in Excel ASBiss Excel Worksheet Functions 1 February 15th 05 11:47 AM


All times are GMT +1. The time now is 07:45 AM.

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"