ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   formula in one cell or another (https://www.excelbanter.com/excel-worksheet-functions/79710-re-formula-one-cell-another.html)

Elkar

formula in one cell or another
 
What you're asking can't be done with worksheet functions. A cell may
contain user input OR a calculated formula. Not both. However, you can
accomplish what you want with VB Code.

Open the VB Editor (Alt-F11) and add this code to the "ThisWorkbook" object.

Dim D, M As Double

Private Sub Workbook_Open()

D = Range("A1").Value
M = Range("B1").Value

End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Range("A1").Value < D Then
D = Range("A1").Value
Range("B1").Value = Range("A1").Value / 8
Else:
If Range("B1").Value < M Then
M = Range("B1").Value
Range("A1").Value = Range("B1").Value * 8
End If
End If

End Sub


Hope that helps,
Elkar


"tjb" wrote:

When the user enters a number in cell A1, I want cell B1 to divide that
number by 8. If A1 is blank then B1 should be blank.

Alternately, when the user enters a number in cell B1, I want cell A1 to
MULTIPLY that number by 8. If B1 is blank then A1 should be blank.

I'm pretty sure this has to be a workbook function but I'm not sure how to
proceed. Any ideas all?



All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com