Value or formula in a cell dependent on another cell

muhleebbin

Active Member
Joined
Sep 30, 2017
Messages
252
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Is it possible to have a value or a formula in H3:H54 that's dependent on J1? Basically trying to build a new rate sheet for the upcoming year and cells G3:G54 have the previous years rates. So depending on how a user would like to use this sheet, they could either fill in a 5% in J1 and H3:H54 would show a 5% increase from the previous year. However some users will probably just populate the individual rates or want to override the calculation with a more palatable amount.

Below is a test sample but I'd like to either be able to override the values of H (like H14) and it still calculate appropriately if J1 is filled in again.

Test.xlsx
ABCDEFGHIJ
1Test5%
2RoomDenOccupancyHelper202120222023 Rates
31 Bedroom100YSingleY|Single9001,0001,0505.00%
4101YDouble AY|Double A8009009455.00%
5102YDouble BY|Double B8009009455.00%
6103Single  
7104Double A  
8105Double B  
9106Single  
10107Double A  
11108Double B  
12109YSingleY|Single9001,0001,0505.00%
13110NDouble AN|Double A8009009455.00%
14111NDouble BN|Double B8009009758.33%
15112Single  
16113Double A  
17114Double B  
18115NSingleN|Single9001,0001,0505.00%
19116NDouble AN|Double A8009009455.00%
20117NDouble BN|Double B8009009455.00%
21118Single  
22119Double A  
23120Double B  
24121Single  
25122Double A  
26123Double B  
27124Single  
28125Double A  
29126Double B  
30127Single  
31128Double A  
32129Double B  
33130Single  
34131Double A  
35132Double B  
362 Bedroom200YSingleY|Single1,2001,5001,5755.00%
37201YDouble AY|Double A1,1001,3001,3655.00%
38202YDouble BY|Double B1,1001,3001,3655.00%
39203Single  
40204Double A  
41205Double B  
42206Single  
43207Double A  
44208Double B  
45209Single  
46210Double A  
47211Double B  
48212Single  
49213Double A  
50214Double B  
513 Bedroom300Single  
52301Double A  
53302Double B  
54303  
Sheet1
Cell Formulas
RangeFormula
F2F2=G2-1
H2H2=CONCATENATE(G2+1," Rates")
H3:H5,H37:H38,H18:H20,H12:H13H3=G3+(G3*$J$1)
H36H36=G36+(G36*J1)
E3:E54E3=IF(OR(C3="",D3=""),"",CONCATENATE(C3,"|",D3))
J3:J54J3=IFERROR((H3-G3)/G3,"")
 
OK so what is the appropriate formula? Do you mean like in cell H3 the formula is G3+(G3*$J$1). Otherwise H3:H54 are empty or what?
Yup. If J1 has a value then H3 should have that formula, otherwise it would be blank.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
The way to do this is to put the formula elsewhere e.g. AA3:AAxx.
In the AA cells you set the rate dependent on the value in J1, or the individual rates if entered.
The H cells use the AA values NOT the J values.
 
Upvote 0
The way to do this is to put the formula elsewhere e.g. AA3:AAxx.
In the AA cells you set the rate dependent on the value in J1, or the individual rates if entered.
The H cells use the AA values NOT the J values
Taking OaklandJim's suggestion of creating a worksheet_change vba and sort of have it working:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False

Dim strFormulas(1 To 1) As Variant

If Not Intersect(Target, Range("J1")) Is Nothing Then

    With ThisWorkbook.Sheets("Bellingham Forecast")
        .Range("H3:H54").ClearContents
    
        strFormulas(1) = "=IFERROR(G3+(G3*$J$1),"""")"
        
        .Range("H3").Formula = strFormulas
        .Range("H3").Copy
        .Range("H3:H54").PasteSpecial Paste:=xlPasteFormulas
        .Range("H3").Select
    End With

End If

Application.ScreenUpdating = True

End Sub

A couple of issues with it are: I'd like to clear all the contents in H3:H54 if J1 is blank or deleted. Also the copy ring on cell H3 continues to show if J1 does have a value. Is there a way to get rid of the ring on H3?
 

Attachments

  • Capture.JPG
    Capture.JPG
    11.9 KB · Views: 5
Upvote 0
Figured out the clearing out of the cells if J1 is blank but cannot for the life of me figure out the stupid copy ring around H3 if J1 does have a value. Also can this code be cleaner???

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False

Dim strFormulas(1 To 1) As Variant
Dim ws As Worksheet

Set ws = Worksheets("Bellingham Forecast")

If Not Intersect(Target, Range("J1")) Is Nothing Then
    
    If ws.Range("J1") <> "" Then
    
    With ThisWorkbook.Sheets("Bellingham Forecast")
        .Range("H3:H54").ClearContents
    
        strFormulas(1) = "=IFERROR(G3+(G3*$J$1),"""")"
        
        .Range("H3").Formula = strFormulas
        .Range("H3").Copy
        .Range("H3:H54").PasteSpecial Paste:=xlPasteFormulas
        .Range("H3").Select
    End With
    
    Else
        ws.Range("H3:H54").ClearContents
    End If

End If

Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top