+ Reply to Thread
Results 1 to 3 of 3

find last row of data and dynamically change formula in that row

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    666

    find last row of data and dynamically change formula in that row

    I've built a workbook as a template to analyze sets of data. The data is a time series of stock prices, with no definite start or end date.

    One workbook may have 1,100 rows, while the next may have 631 rows.

    In each workbook, the pasted data fills columns A through D in a worksheet.

    Columns E through Z in the same worksheet contain formulas dependent on the data in A:D. These formulas make up the "template" which I use to crunch the numbers.

    Here's the challenge: Each time I create a new workbook and paste new data, there is always one cell in one column (H) in which I have to manually change the formula, so that it refers to a different cell than the formulas in the rows above.

    Is there a way to paste data into a worksheet then have the worksheet apply this "fix" to the last row containing a number in column H?

    example: there are 1150 rows of data. Formula H1 through H1149 is =max(A$1:A1149). But the formula for H1150 needs to be "=F1149"

    Please note that once the data is pasted in A through D, my task is just beginning. I have lots of analysis to do, where the results are dependent on the pasted data and various adjustments on my "dashboard." So I don't think pivot tables will work. And, because I'm using solver as part of my analysis in which it performs thousands of iterations to arrive at an optimal result, I prefer not to use arrays, which I understand require lots of CPU power.

    Its fine with me to create helper columns or worksheets.

    Please let me know if I need to clarify, or post a sample worksheet.

    Thanks so much for your help.
    Last edited by jrtaylor; 06-12-2017 at 09:41 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: find last row of data and dynamically change formula in that row

    You could try something like this in cell H1:

    =IF(ROWS($1:1)>COUNTA(A:A),"",IF(ROWS($1:1)=COUNTA(A:A),INDEX(F:F,COUNTA(A:A)-1),MAX(A$1:A1)))

    then copy down. If you have 1150 rows of data (as measured by COUNTA(A:A), assuming there is no other data in that column below the main data), then it should return the value from F1149 in cell H1150 and in cells above that it will return the MAX from A1 to the current cell. Cells beyond H1150 should be blank. You could put =COUNTA(A:A) in a helper cell somewhere, and refer to that cell (3 times) in the formula.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    666

    Re: find last row of data and dynamically change formula in that row

    HI Pete, thanks! I'll give it a go.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How can I dynamically change the format of the Y axis based on the source data
    By rmeister29 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 05-13-2023, 04:10 AM
  2. Dynamically change formula based on today's date
    By gjw1971 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-02-2017, 10:20 AM
  3. Dynamically Change Formula
    By CraigMcKee in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-27-2016, 10:22 AM
  4. Dynamically change data based on parameters
    By MrWicked in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-07-2015, 04:47 AM
  5. Change size of Excel Data Table, dynamically
    By joshjpang in forum Excel General
    Replies: 10
    Last Post: 02-08-2013, 06:26 AM
  6. Dynamically change name of source data in VLOOKUP
    By anayeri in forum Excel General
    Replies: 8
    Last Post: 11-03-2009, 12:41 PM
  7. Dynamically change cell range in formula by background color?
    By albert@netmation.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2006, 05:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1