Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Dual input cells

Is it possible to have two input cells more or less 'alternating' so that
each cell assumes the most recent value in either cell?

An example to illustrate: the two cells start empty. A value is entered in
either of the two cells, and both cells now have that value. Aother value is
entered in either cell, and the two cells now have that value.

Ideally I'd like to avoid using VBA. Any ideas?

Henrik
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Dual input cells

There is no way to do this without a Change event.
Assuming your two cells are A1 and B1:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
End Sub

Regards,
Stefi

€žHenrik€ť ezt Ă*rta:

Is it possible to have two input cells more or less 'alternating' so that
each cell assumes the most recent value in either cell?

An example to illustrate: the two cells start empty. A value is entered in
either of the two cells, and both cells now have that value. Aother value is
entered in either cell, and the two cells now have that value.

Ideally I'd like to avoid using VBA. Any ideas?

Henrik

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Dual input cells

You'll want to disable events in this procedure. Otherwise,
changing one cell will call _Change, which changes a cell, which
calls _Change, which changes a cell, which calls _Change, and on
and on and on.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
Application.EnableEvents = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Stefi" wrote in message
...
There is no way to do this without a Change event.
Assuming your two cells are A1 and B1:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
End Sub

Regards,
Stefi

"Henrik" ezt írta:

Is it possible to have two input cells more or less
'alternating' so that
each cell assumes the most recent value in either cell?

An example to illustrate: the two cells start empty. A value
is entered in
either of the two cells, and both cells now have that value.
Aother value is
entered in either cell, and the two cells now have that value.

Ideally I'd like to avoid using VBA. Any ideas?

Henrik



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Dual input cells

Yes, thanks for the warning, I know it but I always forgot to apply until I
experience the endless loop!

Regards,
Stefi


€žChip Pearson€ť ezt Ă*rta:

You'll want to disable events in this procedure. Otherwise,
changing one cell will call _Change, which changes a cell, which
calls _Change, which changes a cell, which calls _Change, and on
and on and on.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
Application.EnableEvents = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Stefi" wrote in message
...
There is no way to do this without a Change event.
Assuming your two cells are A1 and B1:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
End Sub

Regards,
Stefi

"Henrik" ezt Ă*rta:

Is it possible to have two input cells more or less
'alternating' so that
each cell assumes the most recent value in either cell?

An example to illustrate: the two cells start empty. A value
is entered in
either of the two cells, and both cells now have that value.
Aother value is
entered in either cell, and the two cells now have that value.

Ideally I'd like to avoid using VBA. Any ideas?

Henrik




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Dual input cells

A small point, but I would also name the inputs and use the Intersect method
to pick up the event, so that your VB code is nto going to break when you
move stuff around

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

If Not Intersect(Target, Range("Input1") Is Nothing Then
Range("Input2") = Target.Value
ElseIf Not Intersect(Target, Range("Input2") Is Nothing Then
Range("Input1") = Target.Value
End If

Application.EnableEvents = True
End Sub

Regards

Steve Dalton

"Stefi" wrote in message
...
Yes, thanks for the warning, I know it but I always forgot to apply until

I
experience the endless loop!

Regards,
Stefi


"Chip Pearson" ezt írta:

You'll want to disable events in this procedure. Otherwise,
changing one cell will call _Change, which changes a cell, which
calls _Change, which changes a cell, which calls _Change, and on
and on and on.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
Application.EnableEvents = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Stefi" wrote in message
...
There is no way to do this without a Change event.
Assuming your two cells are A1 and B1:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Range("B1") = Target.Value
ElseIf Target.Address(False, False) = "B1" Then
Range("A1") = Target.Value
End If
End Sub

Regards,
Stefi

"Henrik" ezt írta:

Is it possible to have two input cells more or less
'alternating' so that
each cell assumes the most recent value in either cell?

An example to illustrate: the two cells start empty. A value
is entered in
either of the two cells, and both cells now have that value.
Aother value is
entered in either cell, and the two cells now have that value.

Ideally I'd like to avoid using VBA. Any ideas?

Henrik






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
Setting of input cells as blue font and formula cells as black fon Sunnyskies Excel Discussion (Misc queries) 2 May 14th 07 05:27 PM
Trying to Capitalise on Input to Cells John Excel Worksheet Functions 3 June 23rd 06 03:18 PM
how can i make dual label cells? babanu Excel Worksheet Functions 0 March 27th 06 12:07 AM
Input Cells Frick Excel Worksheet Functions 1 March 11th 06 03:28 AM
Switch cells on input Dan Excel Programming 6 November 18th 05 04:42 AM


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