Excel Formula To Macro Code
Aug 5, 2012I have an excel formula that needs to be converted to macro code. Here is the excel formula->
VB: =MID(A2,FIND("http:",A2),FIND("javascript",A2,FIND("http",A2))-FIND("http",A2))
I have an excel formula that needs to be converted to macro code. Here is the excel formula->
VB: =MID(A2,FIND("http:",A2),FIND("javascript",A2,FIND("http",A2))-FIND("http",A2))
(1) =round(if(bran!g1="raw",if(bran!n1=$f$19,(bran!p1/$g$19)*(bran!n1-$g$19),if(bran!n1>=$f$20,((bran!p1/$g$19)*($f$19-$g$19))+((bran!p1/$g$19)*(bran!n1-$f$19)*2),if(bran!n1=$j$20,((bran!p1/$k$19)*($j$19-$k$19))+((bran!p1/$k$19)*(bran!n1-$j$19)*2),if(bran!n1$f$25,bran!j1*$h$25,if(bran!o1>$f$26,(bran!o1-$f$26)*bran!j1*$h$26,if(bran!o1$j$25,bran!j1*$l$25,if(bran!o1>$j$26,((($j$26-$j$27)*$l$27*bran!j1)+((bran!o1-$j$26)*bran!j1*$l$26)),if(bran!o1>$j$27,(bran!o1-$j$27)*bran!j1*$l$27,if(bran!o1
View 1 Replies View RelatedI use a software to find relationship between some variables. this software can export results (excel mathematical formula) to a text or excel file. I need use this formulas in my VBA codes. but I should convert about 100-150 formula each time, hence this is very time consuming and hard to do that manually. I wondering if there is any macro code or third party software for that?
excel formulas are like this:
VB:
=((1/2)*((((EXP(EXP(EXP(-0.00159049260456001*$A1)))+2.36277505628942)/(LN(1.34876400300668*$B1))+(1/2)*((13.8900474312246)+(EXP(2.22254189839997*$C1)))))+(2.56256412775789*$D1/((1/2)*((1.34876400300668*$B1)+(EXP((1/2)*((EXP(-0.000633515788838835*$E1))+(-15.3575339156491)))))*(-15.3575339156491-1.31506071323009*$F1*EXP(EXP(2.22254189839997*$C1))))))*0.00300997948851126+-0.00736105020728091)
I am calculating the employees time and need the time spent to be categorized as follows
Monday to Friday
06:00 to 09:00 is OT
09:00 to 17:00 is BASIC
17:00 to 00:00 is OT
00:00 to 06:00 is PREMIUM
A2 =Date= 31-07-12
B2 =Start Time = 03:00
C2 = End Time = 23:00
D2 = c2-b2 = 20 hours formatted as [h]
there are situations when end date and time is the next day
E2 = 8 hours
F2 = 10 hours
G2 = 3 hours
Saturday
07:00 to midnight is OT
Midnight to 07:00 is premium
Sunday
all the time is premium
The current code is not working.
View 1 Replies View RelatedI created the following macro (using the recorder), and now need to modify it so that the formula extends to the end of the data (and no further). I would also like to include a total at the end.
Sub ExcessUsage2()
' ExcessUsage2 Macro
Rows("39:250").Select
With Selection.Font
.Size = 8
.Strikethrough = False
[Code0 ....
I am attempting to run a MS Ecel macro that is stored on a MS Excel shared file in a MS Ecel target file (locally stored on my C drive) from a VBA module in Ms Access. That is, from a code i want to open the .xls file that houses the macro, and then open the .xls file that i want to run the file in, and then run the macro.
Here is my situation: the file that houses the macro has the workbook hidden and causes in error.
if i unhide the workbook i get a Run-Time Error 91...object variable or With block variable not set.
if i hide the workbook the vba coding can't find the macro...run time error 1004
once again, i currently have an excel file that houses macro whose workbook is hidden.
does anyone know how this can be accomplished?
here is the ....
I have
1) A worksheet ( named PC OD) with one 80X80 matrix (matrix1)
2) another worksheet (named worksheet2) where I have 2 80X80 matrices (matrix 2 and matrix 3) and the below mentioned formulae
Matrix 2 grabs data off Matrix 1 (cell 'PC OD'!B769 belongs to matrix 1, in sheet PC OD) to round off the values in each of the 80X80 cells : ...
Im trying to autimatically insert a RTD formula in a cell but it is failing trowing the error 1004 : 'runtime 1004: application-defined or object-defined error'
Here is the ....
I've got general ledger information that I export out of my accounting software (see attached spreadsheet). From there, in another spreadsheet I do vlookup formulas to get information from this general ledger. However, in order for the vlookup formulas to work properly in the other spreadsheets, I have to go through this general ledger spreadsheet and manually enter just the first five numerical digits in column A for each Total row. I would like to be able to find a solution that would return just the first five characters of the category (column B found at the top of each section) into the cell in column A on each total row. I usually have to manually enter 50-100 of these many, many times a month so it gets time consuming after a while. I'm using Excel 2013.
View 1 Replies View RelatedI have an excel 2010 spreadsheet that lists all of our vendors and the amount we spent with them over the last year.
I want to know how many of them were local vendors.
I have a list of all the zip codes within a 100 mile radius (there are about 500 zip codes). I would like to write a macro or sort function that searches the entire vendor list and only reports back those vendors that are included in the zip codes I specify.
The columns are as follows:
A B C D E
Vendor City StateZip CodeTotal AP
Vendor 1TROY AL36082527.37
Vendor 2PHOENIXAZ85054100
Vendor 3TUCSONAZ8571416255
I want to keep the all the columns, I just want to eliminate all of the vendors that do not fall within the zip code criteria I set.
I'm using Excel 2010 and XP. I have data in rows 1 -4 that can not be altered. There are headings in Row 5, B-L & Row 6, F-J.
Data starts in Row 7 and follows the headings. This repeats for several thousand rows. I need a way to move Row 6, F-J and put it on Row 5, M-Q
Row 6, F-J and put it on Row 5, M-Q
Row 8, F-J and put it on Row 7, M-Q
Row 10, F-J and put it on Row 9, M-Q
Row 12, F-J and put it on Row 11, M-Q
....
....
....
Then delete blank rows below Row 5
I am needing to write a line of VB code for a macro that will insert a VLookup formula into a cell where the "named" table_array can be a variable. Example of what I am looking at below.
Worksheets("active Worksheet").("active cell").Formula =VLOOKUP(G2,variable,6,False)"
I need it to be imputed in the active cell of the active sheet with the variable able to be gathered possibly from a cell reference. Say the cell c3 on the active sheet says V080606, the formula imputed would be =VLOOKUP(g2,v0806,6,false).
i would like an if macro to pick up if cell dest (i have used a case to define this cell) contains an error or more imoprtantly #REF! then change the offending cells to 0 and put up a message box to put "Check XTA". i have found some that i think may work but i didnt understand them (they had function in them :smask so i couldnt put them in.is there a way to put them in with out functions or could someone point me in the right direction.
View 4 Replies View RelatedI want a Macro to be able to copy a formula down from cell A2 down the entire column within the data range. But, the problem I've got is that the spreadsheets I'll be using the Macro on will be different sizes. Currently, the VBA looks like this:
ActiveCell.FormulaR1C1 = "= LOWER(RC[3])"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A17340"), Type:=xlFillDefault
Range("A2").Select
So the "Destination:=Range("A2:A17340")" part copies the formula into all cells from A2 to A17340. Other spreadsheets might only have data up to cell A200, or Awhatever - is there a way of getting the macro to populate just the cells in column A but only where there is data adjacent in other columns?
Also, I want the Macro to be able to delete all rows wherever "DELETE" appears in a certain column - I had a look at the "Delete Entire Row Based on Criteria" Macro but I'm looking for a fully automated solution, rather than the question boxes coming up and asking which cell/criteria, I need to run this macro on multiple sheets and the criteria/column position will always be the same -
I am trying to reference a cell that displays "#NAME?" due to an unrecognized formula. However, I keep getting an "Type Mismatch" error. Is there a way to reference a file that displays "#NAME?"
Example:
If Sheets("sheet1").Range("B6") = "#name?" Then
Sheets("sheet1").Range("B3").ClearContents
End If
Am trying to get the sheetcalculate to be triggered and execute VBA code when a formula changes its result from positive to negative. The code works fine if I trigger it with a command button click. Auto Merged Post Until 24 Hrs Passes;
View 2 Replies View RelatedI have a front sheet with a list of all the sheets in the workbook in column A.
In column B I need to use the counta function to count the number of entries in the corresponding sheet to column A.
As there are 70 sheets I'd thought I'd use a Macro but I'm having great difficulties. I've done a search but can't find what I'm looking for.
So heres part of my code (it uses loops etc which I've managed but this just errors)
cell.Offset(0, 1).FormulaR1C1 = "=counta(" & str2&" C[-1])-1"
The str2 is the string name to reference the sheet in the formula (for example sheet1), I can't figure out how to enter this into the code so it works and is accepted.
I have created a macro with the below formula in it:
Range("L2").Select
ActiveCell.FormulaR1C1 = "=LEN(RC[-1])"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L234")
Range("L2:L234").Select
I am using column K and it looks up the length of this cell. When I created the formula I was using info that only went to line 234 which was fine. Once I clear the info in column K and input new info it can go further than line 234. How do I get the macro to look up the whole of column k without having to create a new macro each time?
I am looking for something to calculate values based on the past three months. I already have written a macro to retrieve all of the data and just need this as an add-on.
for example, lets say it is 5/31/2012. I have a row with dates going like
10/31/2010 11/31/2010 .........
I want the formula to calculate SUM(march+april+may row 68)/SUM(march+april+may row 59)
I have an input tab where I can select the month, say 5, and get the periods.
3/31/2012, 4/31/2012, 5/31/2012
if I changed the 5 to an 8 it would get 6/31/2012 7/31/2012 8/31/2012
I don't know if i need VBA for this but I am trying to have something to calculate this depending on the period selected in the input tab.
I am using excel 2010. I am thinking something with an offset function and maybe a loop? but still not sure.
I have a template invoice in excel. What I want is a macro code that when it is run the open template invoice should be sent to a specific email address !!
View 5 Replies View RelatedHere is the code I'm working on:
I want this code to replace the value of s with the value of a cell.
sub Macro2()
Dim s As String
s= value of (cell F2)
Range("I8").Select
ActiveCell.FormulaR1C1 = "='[(s).xlsm]Payroll Computation '!R8C11"
End Sub
how do i put a formula using: activecell.formula"=CODE("A")"
with " in it
it just dosent work
and is there a way to use the returned value of these formulee in macros with out actually putting them into a cell
I have a formula that works fine in the cell of an Excel spreadsheet but I'm struggling to translate it into VBA (your help please).
The cell formula is:
=If(B2="", "", B2 & " (version: " & F2 & ")")
I want to iterate through all rows in my spreadsheet (about 2000) incrementing the relevant row numbers in the formula @ each pass - eg changing B2 -> B3 -> B4 etc and F2 -> F3 -> F4 etc where column 'B' contains the name of the product and column 'F' contains the version number, resulting in "Product Name (version: 123)" per row.
The closest I've got to this is:
Sub LookupNameInColumnA()
Range("A2").Select
Dim i As Integer
For i = 1 To Selection. CurrentRegion.Rows.Count - 1
ActiveCell.Formula = "=IF(B2="""", """", B2 & "" Version: 999"")" ' problem line?
ActiveCell.Offset(1, 0).Select
Next i
End Sub
This works OK'ish but I want each line to reflect the different data per row. I'm struggling to increment row 'B' and row 'F' in the formula, having tried "B & i + 1" and "F & i + 1" but am getting confused with quotes and concatenating strings within formulas.
I need a VBA code to create a Text file which should be in the form of DML (my scenario is to get Insert Statements for the Data available in the Excel) from Excel Sheet. And this has to be done by assigning a macro to command button where by clicking on it the DML text file should be generated. Even the syntax for the scenario will do.
View 1 Replies View RelatedWhen I enter data in the cells A1 and B1, C1 needs to calculate the result. (not copy and paste)
For examle: I have formula C1=(A1+B1)/2
C column for formula, but shows result only when there is a data in A and B
I received assistance from NBVC for combining data from two cells. Post http://www.excelforum.com/showthread.php?p=2135144. I need to convert the formula into macro code. I thought I would be able to convert it on my own, but running into some troubles with run time errors. Here is the Excel formula, which is working fine.
View 5 Replies View RelatedI have a formula that I want to insert using a macro, so how do I iterate the * values in this line?
ActiveCell.FormulaR1C1 = "='Sheet1'!R[*]C[*]"
The loop is putting the correct formula into the cell - but THEN... - I wish to (within the loop and before it moves on) check if the value is equal to OR greater than 1 - if it is, make it a value of 1 (this '1' is then used at the bottom of the column of data to give a total). I need to do this before it moves onto the next cell. What am I doing wrong? Is it because once it puts formula in the cell, it then moves down - do I need to select the cell again first? As I had originally posted on this site - link: url]http://www.excelforum.com/showthread.php?t=641970[/url]
View 2 Replies View RelatedI'm trying to set a cell on one sheet to be equal to the product of two cells on another sheet. The problem is that one of the cells on the other page is dependent on the variable T. This is what I've got and it's giving me errors
Worksheets("Output").Range("K14").Formula = "Worksheets("Calcs").Range("D17")*worksheets("Calcs").Range("D17").Offset(10+T,0)"
When I record a macro it gives me this, but again, I need the last cell in terms of "T"
ActiveCell.FormulaR1C1 = "=Calcs!R[3]C[-7]*Calcs!R[14]C[-7]"