Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default Keep relationship between 2 cells that both accept data

I swear I saw someone who posted a trick to accomplish this...

I want the value in cell A1 to always be twice the value in A2, but I want
to be able to enter data into either cell (not a formula).

For example, I type a 2 in cell A1 and A2 returns a 1. I then type 3 into
cell A2 and A1 returns a 6.

Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Keep relationship between 2 cells that both accept data

Very easy with a little event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A2")) Is Nothing Then
Application.EnableEvents = False
If Intersect(Target, Range("A1")) Is Nothing Then
Range("A1").Value = 2 * Range("A2").Value
Else
Range("A2").Value = 0.5 * Range("A1").Value
End If
Application.EnableEvents = True
End If
End Sub

REMEMBER: This macro goes in the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200738


"Arun" wrote:

I swear I saw someone who posted a trick to accomplish this...

I want the value in cell A1 to always be twice the value in A2, but I want
to be able to enter data into either cell (not a formula).

For example, I type a 2 in cell A1 and A2 returns a 1. I then type 3 into
cell A2 and A1 returns a 6.

Is this possible?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default Keep relationship between 2 cells that both accept data

Yes, that certainly works. Now I'm trying to apply it to a more complicated
case...

My worksheet is made up of quarterly and annual data as follows:
Headings: Q1 Q2 Q3 Q4 2006 Q1 Q2 Q3 Q4 2007
Volumes: a b c d a+b+c+d e f g h
e+f+g+h
Mkt Shares: i% j% k% l% avg(i,j,k,l) (etc)

So I want the sheet to work such that if entering a quarterly volume, the
year just sums up the quarters. If entering an annual volume, it just places
in each of the quarters that value divided by 4.

What I would like it to do is this. If you enter a quarterly formula, it
places a formula in the cell for the year. If you enter a yearly volume, it
puts the same number in each of the four quarter cells. For the lines with
percentages it adjusts the formula accordingly.

The issue I have with the code you wrote is that I would have to
specifically identify all the ranges in the code. Is there a way to apply
code to a cell (similarly to how you apply a format) that tells it to do
something to the 4 cells to the left? In other words, I write code that says
when THIS cell is altered, put this number / 4 in each of the 4 cells to the
left. Then I apply this code to each of the columns that have yearly volumes.

Thanks for all your help!

"Gary''s Student" wrote:

Very easy with a little event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A2")) Is Nothing Then
Application.EnableEvents = False
If Intersect(Target, Range("A1")) Is Nothing Then
Range("A1").Value = 2 * Range("A2").Value
Else
Range("A2").Value = 0.5 * Range("A1").Value
End If
Application.EnableEvents = True
End If
End Sub

REMEMBER: This macro goes in the worksheet code area, not a standard module.
--
Gary''s Student - gsnu200738


"Arun" wrote:

I swear I saw someone who posted a trick to accomplish this...

I want the value in cell A1 to always be twice the value in A2, but I want
to be able to enter data into either cell (not a formula).

For example, I type a 2 in cell A1 and A2 returns a 1. I then type 3 into
cell A2 and A1 returns a 6.

Is this possible?

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
Excell cells in worksheet will not accept new formatting. Help Tracey Excel Discussion (Misc queries) 0 April 25th 07 06:32 PM
Excel chart source data y-values can only accept 7 data pts? progprog Charts and Charting in Excel 3 March 14th 07 01:09 AM
Charting the relationship between two cells Andrew Charts and Charting in Excel 3 March 9th 07 05:50 PM
Cells won't accept specific text Dogtown New Users to Excel 3 November 8th 06 12:53 AM
Format cells to only accept numbers cradino Excel Discussion (Misc queries) 4 July 22nd 06 03:46 PM


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