Possible To Set The Value Of A Cell In An Excel Function
Mar 31, 2009
I want to convert an excel spreadsheet into an excel addin file so that users may use the embedded generations of knowledge as excel functions. Unfortunately, I have a problem. I can create macros that allow me to change cells within the spreadsheet and as a result calculate useful values etc, but when I change these macros into functions VBA generates an error wherever I try to change the value of a cell. This appears to be a feature of excel VBA programming. Is there a workaround?
To illustrate what I am trying to do:
The intial spreadsheet (say it is called "MatProps.xls") contains many complicated formulae that calculate material properties. There is a nice user interface where the user enters temperature etc. and there is an output cell where the materials viscosity appears. I want to create a function for example:
Visc(temperature)
If the spreadsheet is saved as an addin, then the user can enter a formula such as:
= visc( 200 )
or = visc ( A2 )
in a new spreadsheet. The function "visc" needs to be able to set the value of the temperature input cell in "MatProps.xls" and then read the viscosity value from the output cell. If "visc" is defined as a subroutine (hence becoming a macro), the input cell can be changed, the output read and everything is hunky dory. When "visc" is changed to a function, VBA can not set a value in the input cell.
View 6 Replies
ADVERTISEMENT
Mar 19, 2014
I am having a formatting issue within a cell. I would like to accomplish a TAB space between to words so they always have the same space between, no matter how many characters the words or numbers have.
Example: I insert text and numbers from different cells in to one.
Formula: ........
It looks like this... so far so good.
25.02.2014 EUR 5'600.00 1.2177 CHF 6'819.12 Withrawal
But if i insert multiple lines with higher or lower amounts the formating goes wrong.
25.02.2014 EUR 5'600.00 1.2177 CHF 6'819.12 Withrawal
26.02.2014 EUR 10'000.00 1.2212 CHF 12'212.00 Deposit
The target would be to keep straight lines like with the TAB in Word.
snap-tab.jpg
I know there is no TAB whitin excel cells, but maybe there is a way to set a default charachter lenght that can be forced even if the amount or the text is shorter.
View 3 Replies
View Related
Feb 19, 2010
i have two excel files, with many data inside
i need a function that do this:
in the cell A1 i want to visualize the cell A1 of second file
in the cell A2 i want to visualize the cell A13 of second file
in the cell A3 i want to visualize the cell A25 of second file
i explain: in the first file i need a column that in each line show the first cell + 12, then +24, then +36.
file 1 is 1.xls
file 2 is 2.xls
for example A1 have the value 1
if in 1.xls cell A1 I insert =[2.xls]worksheet1!A1 and in A2 =[2.xls]worksheet1!A1+12 in A2 i obtain the value of A1+12=13, but i need to obtain the valour of A1+12=value of A13.thanks
View 10 Replies
View Related
Nov 25, 2011
I'd like to know if it's possible (Excel 2007) to insert a function/button into a cell, which when clicked, will paste whatever is on the clipboard?
You can see a screenshot of my document here, and I'd like to insert a paste funtion in the red circle. Is it possible?
[URL]
View 9 Replies
View Related
Feb 14, 2012
What I wanted was to a function, say, "=LastModifiedDateOf(CELL)", where CELL, is a parameter that indicates the cell I want to monitor. If the value of such cell ever gets changed, the cell containing the function has its value updated to the current date.
E.g.
A1 = "AA"
A2 = "=LastModifiedDateOf(A1)" -> "10/03/2011 10:30:32"
-- Make an update:
A1 = "BB"
A2 = "=LastModifiedDateOf(A1)" -> "14/02/2012 12:15:11"
I'm not quite a super user in Excel, but this function would be very very useful for me.
ps. I'm using Office 2010
View 4 Replies
View Related
Jan 10, 2014
Assume you have a rectangular range. Say A1:M18. There are values in some random cells (any number of cells) within the range. The rest of cells are blank. In cell M19 (ie cell below the bottom right corner of the range), I need a excel function that returns the nearest (ie physical location) non blank cell value. I have searched the internet for weeks. The closest formula is the following (see below) but it is flawed as it returns zero if there are values in rows below the row of the nearest cell with non blank...and also zero if there is value in a column greater than the column of the nearest cell with non blank.
Closest formula so far:
INDEX(A1:M18,LARGE(IF(ISBLANK(A1:M18),"",ROW(A1:M18)),1)-ROW(A1:M18)+1,LARGE(IF(ISBLANK(A1:M18),"",COLUMN(A1:M18)),1)-COLUMN(A1:M18)+1).
And the function should be relative not absolute as the range can be extended..but the location of the formula remain same relative to the array size. (ie. always at below the right bottom cell).
NOTE: Ignore the special case where two non blank cells are the nearest. That will not happen.
View 5 Replies
View Related
Apr 12, 2012
I'm working in Excel 2010. I'm trying to create a dynamic range, using the OFFSET function. I've got it working beautifully but as soon as I save it and close the Name Manager the range stops working. When I go back into Name Manager I find all the cell references have changed (from C1:C600 to C1048572:C595 - or some other strange range).
P.S. What it's doing isn't so important as when the cell references are right it works. But just for full info: It's an OFFSET function, starting at A1. It will look at a list of companies and use a Match function to find out how many rows to offset (based on where the first instance of a particular company. And it uses the COUNTIF to make the range the same number of rows as there are entries for that company.
Here is my broken function:
=OFFSET('Map Point'!A1048572,MATCH("Company Name",'Sheet Name'!C1048572:C595)-COUNTIF('Sheet Name'!C1048572:C595,"Company Name"),0,COUNTIF('Sheet Name'!C1048572:C595,"Company Name"))
View 3 Replies
View Related
Apr 8, 2014
I'm having trouble using the worksheet copy command in a VBA subroutine. I have the following line in my code:
[Code] ........
When I step through my code and execute this line, the sheet is copied as expected and put in the correct place, but then instead of the next line of code being highlighted, the pointer jumps to the first line of a function (in a different module) in my code.
View 14 Replies
View Related
Mar 20, 2009
Another interesting dilemma to solve. Using this formula:
View 2 Replies
View Related
May 14, 2013
Function Haversine has correct value in debugger but in cell it has the same value as Haversine2. Is this a known bug?
Public Function Haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
Dim temp As Double
[Code]....
View 9 Replies
View Related
Jul 17, 2008
I have created a List in excel of various tasks. (See attached example.) Each row contains one cell with a function which equals the cell above it and to the right. So the function for cell C3 would be D2. The only importance is that the cell mirrored is always the cell one above and to the right. However, now I would like to be able to rearrange this List, but the “one up and to the right” function will now be all over the place.
Is someone aware of a function which will target a relative location instead of an exact cell?
View 13 Replies
View Related
Mar 2, 2008
I have been looking around have this much code from this site, modified. What I am trying to do is calculate numbers by a position with cells D through K having numeric values. I have 'hardcoded' the cells (D2, E2, etc in the code below), but in reality I only want the current row (so if the formula is on the 2nd row, I want D2, if it is on the 3rd row, I want D3).
My problem is obviously the formula isn't working because I am not correctly tying back to the spreadsheet (Positioncalc.xls). When I put the formula in the spreadsheet it works, but in my script I get 0 everytime.
My Script:
Function Position(rCell As Range, Optional RightPosition As Boolean)
Dim vResult
Select Case rCell.Text
Case "QB"
vResult = (2*D2) + (2*E2) + (2*F2) + (4*G2) + (2*H2) + (1*I2) + (4*J2) + (3*K2)
Case Else
vResult = "Invalid Position"
End Select
If RightPosition = True Then
Position = vResult
Else
Position = "Position not valid"
End If
End Function
So, when I put =Position(A2,True) I expect to see the formula results of those cells calculated based on the position (QB, HB, etc with their unique formulas).
My next challenge after this is to highlight certain cells based on the Position. So if A2 = QB, I want cell D2 boldface and Red, etc. I have seen some scripts on colors and such here, so I might be able to figure it out.
View 9 Replies
View Related
May 23, 2014
see attached excel sheet. On Colum G (highlighted in green) there are hours and minutes. Is there a way I can create a function or macro so that it will convert the values to minutes. For example if the value 1:48 it will convert it 108 minutes or 0:36 will be 36 minutes.
I know I can use =Hour() or =MINUTES() formula but this is long way. My sheet has over 10k data.
Attached file: Book1.xls‎
View 11 Replies
View Related
Oct 13, 2009
On sheet 1 I have a list of 1000 firstnames
On sheet 2 I have a list of 1000 emails,
I need a function that states If a cell in the email column contains a string or value from the names column, it will result in a true statement so that I can separate out the emails that have these peoples first names.
View 5 Replies
View Related
Dec 8, 2009
I am trying to return a TRUE or FALSE based on a date in a cell.
for example:
if cell A1 = 07/11/2009
I want A2 to show TRUE or FALSE if A1 is 14 days or more behind todays date.
I have tried stuff like:
=IF(A1=TODAY()-14,"True","False")
but it just always says false. EDIT: I have just noticed that if I change the date in A1 to exactly 14 days behind todays, it returns TRUE. So, it does work. Do I need to add a GREATER THAN in there?
View 6 Replies
View Related
May 20, 2014
How I could create a search function with this document attached. I want to be able to pull the kids name, location & information over to a search engine when looking for them because I will have over 40 different worksheets with numerous names on each of them.
View 5 Replies
View Related
Jul 23, 2014
In cell A1 we have the word "one", and in B1 we have the word "two". Would it be possible to have a timer function run for 5 seconds, counting from 5 to 0, and everytime the timer reaches 0, the word in A1 is copied and pasted into cell C1, the timer resets and counts again to zero, this time when it gets to zero, it copies and pastes the word in cell B1 to C1. So it's like a flip flop function, with cell C1 changing it's value every 5 seconds. Also, this code needs to start running automatically when the sheet is opened. Is this at all possible with VBA?..
View 1 Replies
View Related
Dec 23, 2009
Kindly help me with the attched file.
I am trying to divide the months into weeks so I could easily identify if a particular date of a month falls on 1st,2nd,3rd or 4th week of the month.
View 6 Replies
View Related
Nov 18, 2011
how to convert a match statement to vba with multiple conditions? I have situations from where it has to match two criteria, to matching six criteria.
=IF(AND(ISNUMBER(MATCH(1,($K$2:$K$393=Y2)*($O$2:$O$393=$D$1),0)),
'ISNUMBER(MATCH(1,($K$2:$K$393=Y2)*($O$2:$O$393=$G$1),0))),1,"")
View 3 Replies
View Related
May 7, 2014
I want to pull the very last odd duplicate. Example below, I want to pull out A3, and C5 and delete the rest. Is there a function that will allow me to do this?
For example,
Column 1 Column 2
A 1
A 2
A 3
B 1
B 2
C 1
C 2
C 3
C 4
C 5
D 1
D 2
D 3
D 4
View 1 Replies
View Related
Jan 24, 2014
The situation I have on my hands is over 200 users, were the majority can't use Excel's built in function to create PDF's.
Yes, I've tried to teach them, but I'm probably not a good teacher.
So, I've resorted to create a button at the top of the worksheet, that says "Create PDF". I thought this was gonna be very easy to program, but alas.
Is there a way to start the built-in Excel dialog that happens when you click "Create PDF/XPS" in "Save & Send"?
View 4 Replies
View Related
Aug 16, 2014
I am trying to do a simple summation between cell A1 and A5. I tried recording this process using the macro, however, this is what i got:
[Code]......
Naturally, i would think the range of the sum function would be:
[Code] ....
As it represents cell A1 and A5. Is there any reason for this misalignment?
View 4 Replies
View Related
Dec 21, 2011
Having problems with the code below on a 2010 Excel spreadsheet. The function flags me at first line and highlights Mid. I get a "compile error, cannot find project or library". I'm trying to set GetSheetName = m_sSheet but the GetSheetName function is not declared as returning any type.
Code:
Function GetSheetName(ByVal m_sFormula As String) As String
Dim m_sSheet As String
m_sSheet = Mid(m_sFormula, 2, InStr(m_sFormula, "!") - 2)
If InStr(m_sSheet, "'") Then
m_sSheet = Mid(m_sSheet, 2, Len(m_sSheet) - 2)
End If
GetSheetName = m_sSheet
End Function
View 1 Replies
View Related
Mar 14, 2012
I have an Excel Workbook with data in Sheet1 and a chart in Sheet2.
I use the OFFSET function to define the data range. In Sheet2, I have 3 cells, B2(column), B4(row) and B6(period). I have slider to adjust the values in B2 and B4.
I define the data range at follow.
Xchart =OFFSET(Sheet1!A1,Sheet2!B4,0,Sheet2!B6,1)
Ychart =OFFSET(Sheet1!A1,Sheet2!B4,Sheet2!B2,Sheet2!B6,1)
When I tired to put in this into value series
=Book1.xlsx!Ychart
The error message ...
Reference not valid. Reference must be to an open Worksheet.
View 3 Replies
View Related
Sep 26, 2012
I need to write a formula in F35 that looks at C4 and if that cell has a # of 25 or greater it will then look at F4 and if that # is greater or equal to 95% it will return a count of 1 in F35. I know how to use the countif function but am stumped when I try to add in the function to look at c4 as a qualifier.
View 7 Replies
View Related
Jun 25, 2013
How to use the Month function in VBA but am not getting the results I expect after reviewing other websites.
I'm running MS Excel 2007.
Simple example:
the worsheet cell, A1 has "5/14/2013" , cell format is DATE
I want to get the month as a number. I know that year(cells(1,1)) results in 2013 so in the immediate window, I try
?month(cells(1,1))
?month(range("A1"))
Both result in Run-time error '13' Type Mismatch.
What am I misunderstanding about the Month function?
View 3 Replies
View Related
Jul 12, 2013
Possible to use concatenate function to enter a formula to a cell and have the cell show the result?
I enter the following in a cell:
=CONCATENATE("=LEN(""",A2,"""",")") 'A2 contains the string "Exchange rate: 925"
what is shown in the cell is:
=LEN("Exchange rate: 925")
If I manually enter the above len function in the next cell, the cell displays 18.
Is it possible to use the concatenate function, maybe combine with other functions, to display 18 in a cell?
View 5 Replies
View Related
Apr 16, 2014
I've been trying to put together a function in excel which will make it simpler and a bit clearer to produce the coefficients of trend lines in cells. I want to produce an excel function like SLOPE and INTERCEPT but for exponential, power and logarithmic trendlines. For example, I can produce the coefficients for an exponential trendline like this:
Code:
=SLOPE(LN(K2:K11);J2:J11)
=EXP(INTERCEPT(LN(K2:K11);J2:J11))
Ideally, I want to be able to do so without the need to convert the terms with LN function, and be able to replace it with a new function that deals directly with an X Range and a Y range
I've produced the following code:
Code:
Function PowerSlope(YRange As Range, XRange As Range)
For Loops = 1 To YRange.Count
YRange.Value2(Loops, 1) = Log(YRange.Value2(Loops, 1))
Next Loops
PowerSlope = Application.WorksheetFunction.Slope(YRange, XRange)
End Function
However, this causes Excel to crash and shut down (not the macro itself, but the entire program). I can't even get the function to run to a break point in the first line before the crash happens. I'm able to remove the FOR ... NEXT loop and use the function to directly return the result of the linear slope, so I'm confident the issue is not in that part of the code.
View 4 Replies
View Related
Nov 22, 2007
=IF(E18>760,(">760"),(IF(E18>550,("550-760"),(IF(E18>365,("365-550"),(IF(E18>210,("210-365"),(IF(E18>120,("120-210"),(IF(E18>90,("90-120"),(IF(E18>60,("60-90"),(if (E18>30, ("1-30"), (0))))))))))))))))
If you try to use this it will not work, as excel takes only 7 arguments
can someone help me with this. Do any one know macro for the same.
if you use this formule it will work
=IF(E18>760,(">760"),(IF(E18>550,("550-760"),(IF(E18>365,("365-550"),(IF(E18>210,("210-365"),(IF(E18>120,("120-210"),(IF(E18>90,("90-120"),(IF(E18>60,("60-90"),(0))))))))))))))
View 9 Replies
View Related
Jul 22, 2012
I'm currently working on my masters dissertation and am using excel 2010.
Basically, I'm trying to generate a list of say, 1000 numbers within a range. I can already do this using the rand() function. However, I need excel to take each random number, apply it into a formula, and then list the answers in a seperate location. This would be easy to do if there was one simple function (which i could just insert into any adjacent cell). The problem is that each random number value is input into a table. The table, which has about 10 columns and 200+ rows, gives one final answer.
I'm sure there has to be a faster way than creating 1000 tables for each random number generated.
Let's say I have a list of 1000 random numbers in sheet 1. the function table is in sheet 2 and produces the answer in the same sheet, in a single cell. I'd like excel to use each random number generated, input it into the function table, attain the answer from the table, and list it in the cell next to the random number.
View 2 Replies
View Related