Excel Equivalent of a for loop - excel

I have a link budget set up in an excel worksheet. The worksheet has one main input cell that the user can change to see how the data rate is affected. I want to make a plot that shows how the result cell (data rate) changes as the value in the input cell goes up. If I were working in python I would create a list of input values using range, loop over each value with a for loop to calculate the result, and append the resulting value to a new list. Then I would plot the results.
I haven't used excel for much in the past so I'm not sure how I would do this in my worksheet. Is there an Excel equivalent of the for loop sequence I mentioned above?

Related

How do I generate a new cell every time my function populates?

I'm trying to create a sheet that acts as a model stock market. I have code to randomly generate a positive or negative percentage to apply to a set(and later varying) principal. Every time I manually calculate my sheet, I need a new cell to generate with the latest balance(principal*random%) while still showing the previous balances. I've tried testing if the cell below is empty and then placing text in it, but once it reads the cell as no longer empty it becomes a circular reference. Ideal I'd like to be able to 1) calculate the new balance after applying the first percentage 2) save the new balance in its own cell 3) read that cell as the new balance while still viewing the initial value 4) repeat the function every time I calculate the page 5) create a graph and later algorithm plotting the points to resemble market trends.
You could use the Workbook_Change() event in VBA and write a short copy and paste script in there to store results of your calculation. You would probably want to combine this with a vba command for finding the last row in your results column to paste the new value.

(Excel) Neither Offset nor Index/Match prevented a table's referenced cell from moving

I have a report that consists of 3 different input, and 3 corresponding output tabs for 3 different sources of information. Each source needed a Macro to change the formatting of the data. One of these sources needs data for individual days, so as it formats the data into a table, it is copying and inserting the cells on top of the previous day's data. Once 5 days of data has been converted and stacked in the output tab, a final tab has essentially all the formula's, dubbed the "Conversion" tab. In this tab there are 3 tables for each source of data (the output tabs) and a fourth that takes the data from these 3 tables, and combines them into what a final macro copies and pastes the values from into a new sheet.
The problem lies in that sheet that stacks the data by inserting the new rows. I've done everything from Index and match, Offset and match, simple offset, Vlookup (obviously, that's the go-to at first) and even Defined the name of new formula's, but the cell that the Conversion tab's table references keeps moving down as new data comes in. I need to reference Array 'CampPerf Output'!B116:B135
no matter what. What formula can I use or backdoor trick can I use so that my lookup looks at the exact same array every time?
The macro that converts the data has to be a repeatable action so I can assign it to a button (This report must be made as simple as possible, as Non-Excel Users need to be capable of "paste data, click button, click other button, ta-da!")
Thanks for any help!
Use this as your range reference:
INDEX('CampPerf Output'!$1:$1048576,116,2):INDEX('CampPerf Output'!$1:$1048576,135,2)
This will always return the range array in 'CampPerf Output'!B116:B135 no matter how many rows or columns are added or removed.

Dynamic chart data series referring to multiple named ranges

I have a chart in Excel 2010, and I want to have a data series that can refer to multiple named ranges based on criteria in another cell. For example, if A1 = 1, the data series will display the data from S_1, and if A1 = 2 it will display the data from X_1. Both S_1 and X_1 are dynamic, and can refer to different data based on other conditions I have.
I've gone into the select data source of the chart, and tried setting the series value of the data series equal to formulas like IF(A1 = 1, S_1, X_1), and CHOOSE(A1,S_1,X_1), but it says these functions aren't valid.
Is the syntax of the formula off, or does excel not accept these formulas in its series value? If it's the latter, what other way is there to achieve the desired result?
I would use another column (could be hidden) to extract the specific data I want to plot.
First, you'll need a list, or some other way to interpret the number in A1 to the specific series you want to show. Than you create a column (for simplicity I assume it is aligned with your data) that fetch the relevant data from the table, and set the chart on it.
Now, step by step:
Define the mapping between the number in A1 and the data series you want to choose. I'll use it as the column number of the data.
Define all the data range as a named range, say data.
Take a new column, and paste this formula in row 1:=INDEX(data,1,$A$1), This will bring the header.
In the cell below type: =IF(ISBLANK(INDEX(data,0,$A$1)),NA(),INDEX(data,0,$A$1)) to bring the data from the relevant series, or #N/A if it's blank.
Drag the 2nd formula all the way down to the lowest row in which any of the series has data in it.
Create a chart based on the new column, and watch how you can chang the value in A1 and see the chart updates.
Tell me if it answers your question ;)

Draw a chart in excel based on a string appearance

I have an excel file that contains 6 different sheets and every sheet contains some cells that there's text value inside them.
Now, I want to draw a chart that shows how many times a string was revealed in a larger string.
As much as I could find in google search, excel will draw charts based on numeric values,
So, I need to know is there a way that draw a chart based on text with my criteria?
Thanks in advance
UPDATE :
Assume that I have values like this:
And I need to know how many times a string appeared in B cells for every program.
And What if program name was in another sheet and string col was in someone else.?
No, Excel cannot chart anything based on text. You need numbers. In order to get these numbers you can apply different techniques, like formulas or VBA to analyse the text and produce the respective numbers. If you need more detail, provide more detail about your data.
Edit after question update: Consider this screenshot
the formula in C2 is
=ISNUMBER(SEARCH($G$1,B2))*1
The table in columns F and G is a pivot table with "Program" dragged to the rows area and "found" dragged to the values area and set to sum. This table can be used for charting.
If the program and the string are in two different sheets, you can still use formulas to construct a data source for the pivot table.

Lookup values in an unknown range - Excel

Is there any way to look up and display the latest value in a group that does not have a set range?
Here's a breakdown of a question. I am working with some data that I like to break into data groups that can be collapsed. On a weekly basis I un-collapse the group and insert a line at the bottom with the new information. I would like that latest bit of information to be automatically displayed on the top cells that is displayed when collapsed.
I have used look-up tables and I have a function that I used for testing purposes: =LOOKUP(2,1/(C5:C11<>""),C5:C11) that obtains the last cell within that designated ranged: C5-C11.
Now can I do something similar within grouped data values that have no defined range?
One way to do this is with an index function, assuming that there are no other rows of data on this worksheet other than the group that you're trying to find. Here's an example of a formula that could work for you. It assumes that your data starts in K2 and you want to have your result in K1.
=INDEX(OFFSET(K2,,,ROWS(K:K)-ROW(K2),1),MATCH(9.99999999999999E+307,
OFFSET(K2,,,ROWS(K:K)-ROW(K2),1)),1)
The offset creates an array for all cells below k1 without counting k1. The match function searches for the largest number possible, this formula assumes that you're looking for numbers. If you're looking for text, or a combination, you'll have to use a different formula by replacing the match portion with:
MATCH(REPT("z",255) 'for text
MAX(MATCH(9.99999999999999E+307,range),MATCH(REPT("z",255) 'for numbers and text
Source: http://www.techonthenet.com/excel/questions/last_value.php

Resources