dynamic range with formula

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Is it possible in excel to only apply a formula to a range, based upon the amount of values in another range?


To keep it simple, as an example if I have a formula which says $B1 = $A1+1 from B1-B5. But then I add a value into A6 I want the formula to automatically be input into B6.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hello,

To automatically enter the formula would take some VBA.

Here is a formula that will only show if an entry is made:

<TABLE style="WIDTH: 200pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=266><COLGROUP><COL style="WIDTH: 200pt; mso-width-source: userset; mso-width-alt: 4864" width=266><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #d7e4bc; WIDTH: 200pt; HEIGHT: 15pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl63 height=20 width=266>=IF(A1="","",$A1+1)</TD></TR></TBODY></TABLE>
 
Upvote 0
Right click the sheet tab. Select veiw code then paste this:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br><br><SPAN style="color:#00007F">Dim</SPAN> Changed <SPAN style="color:#00007F">As</SPAN> Range<br><br><SPAN style="color:#00007F">Set</SPAN> Changed = Intersect(Target, Range("A1:A100"))<br><br><SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> Changed <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN><br>    <br>    <SPAN style="color:#00007F">If</SPAN> Target.Value = "" <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>    <br>    Target.Offset(0, 1).Formula = "=A" & Target.Row & "+1"<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
that should be the default behavior...

Check in Tools - Options - Edit
put a check on "Extend data range formats and formulas"
 
Upvote 0
Yeah, it might be that I'll just do it in vba.

My formula isn't actually as basic as the example, and I tend to place if or iferror statements around them to not show invalid values. However the problem is that because generally I'm dealing with data extracted from elsewhere the amount of data can vary massively dependant upon the timescale being looked at.

If someone looks at data over the past day, it might only be 1000 cells, where as over the year it might be 300,000. I don't really want to place the formula into 300,000 cells if the majority of the time 1000 would do, as it makes the workbook very large in terms of Kb's.
 
Upvote 0
Jonmo, I am using Excel 2010 would this be the checkbox that says 'Enable iterative calculation'?

repairman615, thanks for providing the VBA, I will give that a try if I can't get it to work by default
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

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