Excel question
#1
Original Poster
FlyerTalk Evangelist


Join Date: Feb 2005
Location: RSE
Programs: AA Exp|VA Platinum
Posts: 15,913
Hi
This is probably a little OT but I'm trying to do a new price list and am wondering if is there anyway that you can have two cells interdependant on eachother....
ie I have a cell called "Sale Price" and another called "Mark-up". Currently prices are done off Markup, (Sale Price= Markup*Cost Price). Is there anyway that you can either change "Sale Price" or "Markup" and the other will change, so I could either set the mark up or the sale price and the other would fill?
Thanks
This is probably a little OT but I'm trying to do a new price list and am wondering if is there anyway that you can have two cells interdependant on eachother....
ie I have a cell called "Sale Price" and another called "Mark-up". Currently prices are done off Markup, (Sale Price= Markup*Cost Price). Is there anyway that you can either change "Sale Price" or "Markup" and the other will change, so I could either set the mark up or the sale price and the other would fill?
Thanks
#2
Join Date: Nov 2004
Location: SYD
Programs: QF Plat & Lifetime Gold, Velocity Gold, SQ PPS
Posts: 247
#3
Original Poster
FlyerTalk Evangelist


Join Date: Feb 2005
Location: RSE
Programs: AA Exp|VA Platinum
Posts: 15,913
#4
A FlyerTalk Posting Legend




Join Date: Feb 2001
Location: Berkeley, CA USA
Programs: Piggly Wiggly "Shop the Pig!" Preferred Shopper
Posts: 60,660
Have you considered whether using conditionals ("IF") might work for you? Take a look at the IF function in the help menu and see if you might be able to use it for your situtation.
#5
Original Poster
FlyerTalk Evangelist


Join Date: Feb 2005
Location: RSE
Programs: AA Exp|VA Platinum
Posts: 15,913
I have but I would still end up with a circular ref, wouldn't I? Unless I created a third point....I'll have to investigate.
#6
Join Date: Jul 2006
Location: LAX
Programs: UA 1P MM, SPG Lifetime Gold
Posts: 654
Try having 2 sets of the 3 columns (Sale price, Markup, and Cost). One set is your data entry set and the other would have IF formulas. You should then be able to enter any 2 of the 3 and have the 3rd calculated, with the other 2 carried over.
#7
Original Poster
FlyerTalk Evangelist


Join Date: Feb 2005
Location: RSE
Programs: AA Exp|VA Platinum
Posts: 15,913
Thats done the trick thanks. Is there anyway now I can get the numbers in the data entry set to update to the data in the IF formulas as in if i enter say m/up and cost and it fills the fields in the "IF formulas columns" can I get it to reverse back and fill the blank sale price cell in the data entry set or is this circular???
thanks for all you help everyone
#8
Join Date: Oct 2004
Location: Atlanta
Programs: Delta Silver, UA Premier, National Executive, Hilton Gold
Posts: 265
#9
A FlyerTalk Posting Legend




Join Date: Feb 2001
Location: Berkeley, CA USA
Programs: Piggly Wiggly "Shop the Pig!" Preferred Shopper
Posts: 60,660
#10
Join Date: Nov 2000
Posts: 7,700
#11




Join Date: Apr 2006
Location: CO hublette
Programs: UA AU MM,HH Diamond,Hyatt Globalist , Marriott Gold
Posts: 2,316
Well, there is kind of a way to do it with just the three columns (Sale Price, Markup and Cost).
A formula will give you the circular reference, but you can use VBA code to get around that.
if you were to write a macro on the worksheet, under the Change event you can do it. For example, the data you are trying to manipulate is on a sheet called Margin which is the first sheet in the workbook.
If you open the VBA editor (F11) then double click on Microsoft Excel Objects, Sheet1(Margin) and change the lefthand dropdown from General to Worksheet, then change the righthand dropdown to Change you will get the lines below in Blue. Put the lines in Red between the others, and anytime you make a change on that worksheet, this macro runs. (note, there are three lines that will turn green in VBA, they are the comments)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim intSalePriceColumn As Integer
Dim intMarkupColumn As Integer
Dim intCostColumn As Integer
' determining which columns have the data
For x = 1 To 256
If Cells(1, x) = "Sale Price" Then intSalePriceColumn = x
If Cells(1, x) = "Markup" Then intMarkupColumn = x
If Cells(1, x) = "Cost" Then intCostColumn = x
Next x
' if you have just changed the sale price, calculate the markup
If ActiveCell.Column = intSalePriceColumn Then
Cells(ActiveCell.Row - 1, intMarkupColumn) = FormatPercent(Cells(ActiveCell.Row - 1, intSalePriceColumn) / Cells(ActiveCell.Row - 1, intCostColumn), 1, vbTrue, vbTrue)
End If
' if you have just changed the markup, calculate the sale price
If ActiveCell.Column = intMarkupColumn Then
Cells(ActiveCell.Row - 1, intSalePriceColumn) = FormatCurrency(Cells(ActiveCell.Row - 1, intMarkupColumn) * Cells(ActiveCell.Row - 1, intCostColumn))
End If
End Sub
A formula will give you the circular reference, but you can use VBA code to get around that.
if you were to write a macro on the worksheet, under the Change event you can do it. For example, the data you are trying to manipulate is on a sheet called Margin which is the first sheet in the workbook.
If you open the VBA editor (F11) then double click on Microsoft Excel Objects, Sheet1(Margin) and change the lefthand dropdown from General to Worksheet, then change the righthand dropdown to Change you will get the lines below in Blue. Put the lines in Red between the others, and anytime you make a change on that worksheet, this macro runs. (note, there are three lines that will turn green in VBA, they are the comments)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim intSalePriceColumn As Integer
Dim intMarkupColumn As Integer
Dim intCostColumn As Integer
' determining which columns have the data
For x = 1 To 256
If Cells(1, x) = "Sale Price" Then intSalePriceColumn = x
If Cells(1, x) = "Markup" Then intMarkupColumn = x
If Cells(1, x) = "Cost" Then intCostColumn = x
Next x
' if you have just changed the sale price, calculate the markup
If ActiveCell.Column = intSalePriceColumn Then
Cells(ActiveCell.Row - 1, intMarkupColumn) = FormatPercent(Cells(ActiveCell.Row - 1, intSalePriceColumn) / Cells(ActiveCell.Row - 1, intCostColumn), 1, vbTrue, vbTrue)
End If
' if you have just changed the markup, calculate the sale price
If ActiveCell.Column = intMarkupColumn Then
Cells(ActiveCell.Row - 1, intSalePriceColumn) = FormatCurrency(Cells(ActiveCell.Row - 1, intMarkupColumn) * Cells(ActiveCell.Row - 1, intCostColumn))
End If
End Sub

