Converting Formula To Static Code
Apr 24, 2009Converting formula to static code. I am currently using the following code on a spreadsheet:
View 3 RepliesConverting formula to static code. I am currently using the following code on a spreadsheet:
View 3 RepliesI have a working formula that I want to convert to vba code... I only want to store the formula result in each cell in my range, not the formula itself. It is an ARRAY formula (entered with CTRL + SHIFT + ENTER) and it would be ideal if it could follow R1C1 format to keep it relative for each cell.
Here is the formula as it's entered in my spreadsheet:
=INDEX(PerfMetricTbl!$U$2:$U$250000, MATCH(1, (PerfMetricTbl!$A$2:$A$250000=$A2)*(PerfMetricTbl!$D$2:$D$250000=$D2)*(PerfMetricTbl!$Q$2:$Q$250000=$Q2)*(PerfMetricTbl! $R$2:$R$250000=Z$1), 0)))
I am not super familiar with using INDEX/Match combos which is why I am struggling with this one...
The end result should be:
For each cell in myRange
cell.value = 'Formula result here
Next cell
-OR-
If possible to fill the range in one step:
myRange.value = 'Formula Result Here, utilizing R1C1 relative reference... (this may be a stretch given the range is 55krows x 18 columns)
The problem at hand is I need to fill a range of approx. 999,000 cells with values and the values are a VLOOKUP with 4 matching criteria. So returning the value from Col U on my LookupTbl when the criteria in Col's A, D, Q, and R are an exact match to my values in A, D, Q, and Z:AQRow1.
I'm having a slight problem as I cannot find a way to translate the following code from my worksheet formula to VBA: =IF(LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))=1,A1,MID(A1,1,FIND("-",A1,FIND("-",A1)+1)-1)). The code takes a value from one cell and takes the part that I need. There are two main types of inputs, they are in the form:
aaa-aaaaaaa-aaaaaa
aaaa-aaaaaa
The lengths are variable, but for the sake of showing you an example I have simplified it to the previous. The formula takes the part of the string that is before and after the first hyphen and puts it in the cell next to it.
My DB is in table format . I use this table as source data for 2 barcharts and 1 pie chart.Following are my table headers
Costs|exp heads|Month1|Month2|...|Month n|Spark lines|Average
When i add a month coloumn,Sparklines and Average coloumn should get updated automaticaly.Now this is not happening even if the data is in table format.I also want the graphs to be automaticaly updated.
Today() provides a dynamic date which always equals the current date - not very useful when dating accounting documents. Is there a function that will allow the use of Today(), at the time of the document creation, but will then freeze the date to the date of creation?
View 5 Replies View RelatedI have the following code that places a formula into the cell.
View 5 Replies View RelatedI have a formula in column A, =AVERAGE(C2:Z2). I have a macro that moves columns C to Z over one column to the right every day. How do I keep the above formula the same as it is now. At present the range also moves one column. I have added $ but it still changes
View 5 Replies View RelatedI have 2 sheets in a work book. In the first sheet in A27 I have a value. In the secend sheet I have a formula "=SHEET1!$A$27".
Problem is when I insert a new row in sheet 1 the formula in sheet 2 changes to "=SHEET1$A$28" and I want the formula in sheet 2 to stay the same that is, always =SHEET1!$A$27.
Is there a way to make the last two parts ("height" and "width") of the OFFSET statement formula static (meaning they alway refer to the same cell)? I am inputting a different number in the "colum" section of the formula and every time I do...it changes which cells the "height" and "width" refer to.
View 6 Replies View RelatedHere is what I currently have to make the cell blank and highlighted yellow in the event the date in K1 equals the second day of any month
=IF(DAY(K$1)=2,"","N/A")
Conditional formatting is just =DAY(K$1)=2
What I need to do is apply these same conditions to the cell if the date in K1 is equal to 02/10/10 or 04/10/10 or 06/10/10 or 08/10/10 or 10/10/10 or 12/10/10
what type of vba code I could use to populate a static date and time that I could plug into a formula. Basically what I need is:
IF A1<>"" then L1 shows the date and time of the entry. If A1="" then L1 remains blank. I don't want the date to change once it has been entered.
Let's say I have a value in B2, and a formula in C2. If I drag the formula from C2 all the way down to C20 (spreading it 18 times), the formula wants the value in B2, B3, B4, etc.. down to B20. How do I drag a formula, but have it always reference B2?
View 1 Replies View RelatedI've posted this question in another site http://en.allexperts.com/q/Excel-105...xExp_72253.htm , but i haven't gotten any answer. I'm attaching an example of the file to show an idea of what i'd like to do, please check first. As you can see, i have a Due Date and Priority columns. The Due Date column has a formula, that when i choose the Priority level, it calculates the Due Date from the current date and auto populates in the cell. The problem is, when i open the file the next day, and insert another Priority level, it updates everything even the previous Due Date entry. This is the formula i have in place for the Due Date:
=(TODAY())+SMALL(IF(WEEKDAY((TODAY())-1+ROW(INDIRECT("1:"&(VLOOKUP((B3),{"Urgent",1;"High",14;"Low",21},2,0))+ ROUND(30*((VLOOKUP((B3),{"Urgent",1;"High",14;"Low",21},2,0))/30),0))))<6,ROW(INDIRECT("1:"&(VLOOKUP((B3),{"Urgent",1;"High",14;"Low",21},2,0))+ROUND(30*((VLOOKUP((B3),{"Urgent",1;"High",14;"Low",21},2,0))/30),0)))),(VLOOKUP((B3),{"Urgent",1;"High",14;"Low",21},2,0)))
Is there a way to make up a vb macro to be able to make the Due Date output static, without affecting the formula?
I have the following VBA code, which works nicely -
PHP For Each C In Sheets("data").Range("A2", Range("A2").End(xlDown))
C.Offset(0, 5).FormulaR1C1 = "=IF((RIGHT(RC[-1],3)=""ago""),RC[-1],"""")"
Next C
What I want to do is Paste As Values to each of the cells in the above to convert the formula to a static value,. Is there a simple bit of code I can include in the above loop, instead of doing a Selection.Copy Selection.PasteValues etc over the range?
I have a problem using indirect in a counta function. Basically, I want to count the number of used cells in a range. However, there would be insertions to the rows (using the insert row) on top of the range.
my function is now =counta(indirect(" events database"!"A"&M22&":A"&M500)
However, this formula returns an error. What have I typed wrongly?
I have one worksheet which comes out of an online application (for the purposes of this example I will call it "Online Sheet"). The column headings in this sheets are always named the same but could theoretically appear in any column address. For example, the column header "Completed" could appear in column "X", or "AT", or "ZZ".
On a second sheet (called "Code Sheet") I have to unscramble all of this data into a standardize layout. Each row value has a unique ID which appears on both the "Code Sheet" and the "Online Sheet". However, in the "online sheet" the unique ID could also appear in any column. Like the "Completed" column this column also has a unique column heading ("Unique ID").
Using Match I can calculate the column number in which the "Completed" column appears in this instance of the online data. For example, "Completed" = Column "25". However, I now need to use some lookup function on this column based on the row in which my "Unique ID" appears of the "Online Sheet" (which could of course be in any column in the "Online Sheet").
For example, if "Completed" is in column "25" and the "Unique ID" which I am referencing on the "Code Sheet" appears on row 14 in the "Online Sheet", then the lookup formula must return the value of column 25 row 14 on my "Code Sheet".
Is there a way that formula links in spreadsheets can use environment variables to reference formulas in other spreadsheets/addins?
For example, I have a spreadsheet that imports templates which call functions in an addin. The spreadsheet, templates and the addin could be installed into either the 'Program Files' or the 'Program Files (x86)' folders.
I am experiencing issues with the formula references when moved between 32 and 64 bit computers since Excel seems to store the full path of the addin in the Excel formula (even though it hides it when the reference resolves its path) in my templates. I would like to update the references in my templates so that they use an environment variable (set by my software installer) to always know the correct path of the addin.
In Excel 2003, spreadsheet links are edited via: 'Edit'->'Links'
In Excel 2007 and higher,'Data'->'Edit Links'
I making a template for multiple users to import data into for analysis. I want them to be able to delete and drag-and-drop data to get rid of any bogus values. However i need forumlas that reference those to NOT follow the values as there as moved. As a simple example say you have two columns, column A is a set of random numbers, column B is the number from coumn A times 2. If take the bottom half of column A and drag it up one cell, overwriting a cell, now the cell in column B next to the overwritten cell has a #REF err and ever cell below that now references a Cell in column A from the previous row. I want a formula that references a static address and will not follow the cell if it is moved.
If I use named ranges rather than specific cells references it works for the above example, however for my actual form it does not. Even though the ranges and formulas stay the same I start getting incorrect values. If there is no other way to this I will try to figure why the named ranges do not work.
Wondering where this code can be adjusted to be much more efficient. Right now it is going through 1000 rows and 14 columns and it is taking about 10 minutes. I eventually need it to go through 6000 rows and 32 columns..
I already stored the HexToDec(Cells(x, 1)) result to variable H2D and it didn't really make too much of a noticeable difference.
I'm trying to convert my nested if statement below into vba code.
=IF(L27=15,"15+", IF(AND(L27>=5,L27
I created this code in Excel 2007 now i want to put it on my other users machines they are using Excel 2003 and i keep getting debug errors can someone help
Sub setup()
' Keyboard Shortcut: Ctrl+Shift+C
'add sheet
Sheets.Add After:=Sheets(Sheets.Count)
'format headers
With Range("A1")
.Value = "Job Name"
.Name = "Arial"
End With
With Range("A2")
.Value = "Quote #"
.Name = "Arial"
End With
With Range("A3")
.Value = "Job #"
.Name = "Arial"
I have very little experience with Excel. What I am trying to do is to convert a timecode in this format 00;22;21;00 that is 22 min 21 sec and 00 frames to a serie of numbers that I have hard time to figure out. Example
00;22;21;00 = 13410000000
I want to be able to paste the timecode from premiere 2.0 (00;22;21;00) into a Excel cell that would automaticly convert it to (13410000000) so that i can eventualy generate a .txt file that would look like this:
<Scripts >
<Script Type="URL"
Command="http://www.softfx.com/slide01"
Time="13410000000" />
</Scripts>
My question is about converting a Literal String to Character Code. I'm using the following coded InputBox. And it prompts the user for what characters to search for in a string.
View 4 Replies View RelatedI have a bit of code that is grabbing only the first 9 positions of an alpha-numeric string. The problem I am running into is that when the alpha-numberic value contains an "E", the code turns it into an exponential number in error.
For example, I have the following in column G: 01877E107000. When I run the code, it turns into an alpha-numeric value. The result should be 01877E107 (in column K). I tried using the text function within the code.
I need a formula that converts time in the format of hh:mm to 00:mm. I only want the minutes.
View 4 Replies View Relatedcreating a formula that would convert a string like 63008 (Mdyy format) to a format that Excel can read as a date
=IF(LEN(I2)=5,DATE(20&RIGHT(I2,2),LEFT(I2,1),MID(I2,2,2)),DATE(20&RIGHT(I2,2),LEFT(I2,2),MID(I2,2,2)))
In other words IF(the length of the cell value is 5, parse the date this way, otherwise parse it another way)
If I2=63008, this would output 6/30/2008
I want to convert this to a function since that formula is rather tedious to type out, but I am new to Excel programming
I have an excel work book where in one page (sheet1) contains formula types to be used based on a code. and in the other page (Sheet 2) when I enter the code I need it to get the formula from 1st page and then do the calculation in the second based on the code. Ex : Sheet 1
Code Formula
0 Cell A * CellB
1 Cell B - Cell A*5%
2 (Cell A + Cell B)*10%
In Sheet 2
Cell A B C D ..........
Price(A) Units(B) Code Amount
100 5 0 500 (100*5)
100 5 1 answer (5 - (100*5%)
100 5 2 answer (100+5)*10%
I hope you got the picture. The problem is I'm not sure how to take only the formula from 1st sheet and then use it in the 2nd sheet to do the calculation.
I wont mind using a form for this even.
I have a column with names, where i need the 1st letters of the Names to be displayed in CAPS. If its a Single letter also, the same should be displayed in CAPS
View 2 Replies View RelatedI have two sheets, the first called 'AF' and the other called 'POR'. For one of the columns in the 'AF' sheet I used the following formula - VLOOKUP(B2,POR!$A$2:$A$111254,1,FALSE) to retrieve a string consisting of 7 numerical digits (Ex. 4678451). Now if I want this result of 7 digits in the same 'AF' sheet to be converted to the word "YES" - how do I achieve this? (All the 7 digits numbers are different or unique). Is there some sort of REPLACE command I use here or some other means?
View 2 Replies View RelatedI have whole bunch of formula's added to cells by code. So far so good. How could I then set in macro code that the result is stored in cell as value rather than formula? Now when I go to cell you can see =PIBVSearch(.... yadda yadda yadda in the field above.
I would prefer to change it so that content of cell changes to it's value so there's no formula visible(and above all not stored to harddisk(LOTS of disk space lost. Whole project started to trim down 269Mb excel file into smaller piece! I don't want it to go back there too easily...) or in danger of getting updated which might take a very long time easily).
Code works so that as long as there's rows which haven't got update yet but do have product run code(or something like that. Not quite sure what that number is but I figure it's product run) after code reached that far(which it copied from another file). Then for each row it calls functions for each cell which are responsible for filling invidual cells.
So either way to replace content of whole row with values or invidual cells, I can insert both into loop easily though whole row after cells are calculated would be a) faster to add(just one place to add, not 30...) and likely faster to run(project is about getting the file to run faster afterall...).