Writing A Formula To Cell
Jul 20, 2006
Until now, I have been using the terrifically inefficient way of writing in a formula in a cell and copy pasting the value in my VBA
Easy example (concatenating):
Sheets(Sheet2).Select
Range("D1").Select
ActiveCell.FormulaR1C1 = _
"=""Data collected on ""&TEXT(NOW(),""dd/mm/yyyy"")&"" at ""&TEXT(NOW(),""hh:mm"")"
Range("D1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
More complex example (with IF statement):
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=IF(LEFT(RC[-3],13)=""No list found"",""Data requested for ""&update!R[2]C[-1]&""/""&update!R[2]C&""/""&update!R[2]C[1]& "" out of range"",""Data downloaded for ""&update!R[2]C[-1]&""/""&update!R[2]C&""/""&update!R[2]C[1]& """")"Range("D2").Select...............
View 4 Replies
ADVERTISEMENT
Apr 8, 2014
I have a reference written as a string in cell "AS4", the string is results!A4
I want to write that same reference in cell "as5". I have written the following
[Code] .....
However, cell "as5" returns the string as =results!'A4', with single quotes around A4
Therefore the reference isn't working.
View 2 Replies
View Related
Aug 17, 2007
I have a cell in which I use the following formula:
View 13 Replies
View Related
Dec 29, 2013
I'm working with a multi-page workbook I use for work scheduling purposes.
This is how Sheet1 is set-up:
A
B
1
Name
[Code]....
In the cells in Column D I have used the following formula =IF('Sheet1'!B2="Yes","Holiday",""). What I have realized is that this formula is quite limited. For example not all 12 colleagues work everyday and they work different shifts on different days- each day's data is sorted so that the colleagues are organized primarily by Shift start time and then alphabetically by name- consequently if I used this formula across the entire workbook the Sheet1B2 data may not be consistently referencing the same colleague.
I was wondering if there was a way to amend the formula so that if a colleague is marked as 'Yes' in Sheet1, 'Holiday' could be inserted in Column D in the rows corresponding to where the colleague's name appears?
View 3 Replies
View Related
Feb 13, 2014
I'm trying to create a "master file" that can be used later (a tool other uses can pull up) on with datasets of varying size. I'd like to "data dump" a table of individuals with subsequent columns of various characteristics, then automatically compute various things. So then a user can dump their data into my file and "get the answer" immediately. I've seen some stuff on running one calculation on a dynamic number of cells, but let me illustrate why this is different. I want to perform a dynamic number of calculations, see below:
Each row (record) is a person, with some characteristics (numerical). Ultimately I have a few columns on the end with some computations (Excel formulas) I'd like to do. I'd like to do this for each person (that is, each row) in that data that I dump in. But the thing is, ahead of time we don't know how many people will be dumped in, and that changes (because I'd like this to be a tool...). So how do I tell Excel to compute things if there is a person in that row, but do nothing and leave cells blank if there isn't a person? Ideally I don't have millions of ifs testing for blank cells either. I'd like to do this with Excel functions only and not VBA, if at all possible.
View 1 Replies
View Related
Apr 25, 2006
When I am writing a formula that includes a lookup, it returns the # NAME? error in the spreadsheet. If I delete the trailing ), retype it, and hit enter then the formula returns the correct value. How do I get the formula to work correctly as it is written to the sheet from VBA!
Here's the line of code that writes the formula to the worksheet:
TBox.Range("A3").Offset(i, 3).FormulaR1C1 = "= ROUNDUP((8-(VLOOKUP(RC[-3],K:L,2,FALSE)/1.2))/RC[-1]*1.2,0)"
View 4 Replies
View Related
Jan 8, 2009
I have a question with picking out certain word in the column. I am trying to write a formula that would allow me to pick out names that has first 3 alphabetical letters from the columns. The column has a lot of different names, but the one that I would want my automation to pick out is similar to this, C, AR, AA-103, BG-2056, HJE-1100, etc. However, in the same column, I have other words like elevtar, hsvte, lvnrm, etc. that I do not want my formula to pick out.
View 9 Replies
View Related
Jul 10, 2014
I have a model that makes projections based on annual growth rates. However, I need to evaluate the data based on monthly intervals. With an 8% return on an investment of $1,000,000 my ending balance at the end of the year should be $1,080,000 and in year 2 it would be $1,166,400 and so on. In order to evaluate the monthly data I need each month in year 1 to be based off $1,000,000, so it would be 8%/12=.006666% or $6,666.66 per month. The next year would be based off $1,000,000 + (6,666.66*12) = $1,080,000 and each month would be $7,200.
writing a formula to evaluate over 360 periods.
View 5 Replies
View Related
Jan 21, 2010
I have a problem, basically im writing in the cell but it keep going along, i want it so when i press enter it creates a new line in the cell, so i can have two lines of text in one cell. do i have to do something in the text settings?
View 2 Replies
View Related
Apr 15, 2009
I'm working on creating an array of letters. I'm then writing that array into a cell. The following code is for writing the letters "ABC" into a cell with an array.
View 4 Replies
View Related
Jun 16, 2013
Process is that I read in lines from a text file and then based on a filter I then write some those values to a sheet. One of the values I transfer is always 5 characters with a trailing space. The first four may be all numbers (e.g. "0013 ") or a mix (e.g. "013G "). When I write these to the spreadsheet the ones without letters always end up as a number (e.g. "0013 " become 13). How do I force the cell to show all values as text in the cell just like I read it in. In fact, I'd prefer stripping out the trailing space but it's not critical. That I can do (TRIM).
View 4 Replies
View Related
Aug 8, 2006
I have a combobox that the user selects a value from. Depending on what value is selected i want to write three different numbers to three different cells. I pretty much need to know how you get VBA to put a number in a cell. The numbers are nowhere on this sheet. Just in the code.
Case "1"
Sheet1.Range("M31").Activate
ActiveCell.Value = "1"
Sheet1.Range("O31").Activate
ActiveCell.Value = 0
Sheet1.Range("Q31").Activate
ActiveCell.Value = 0
Case "2"
Sheet1.Range("M31").Activate
ActiveCell.Value = 2
Sheet1.Range("O31").Activate
ActiveCell.Value = 0
View 8 Replies
View Related
Oct 2, 2008
I'm looking for a complete working example of how to write a single cell to a Access table using a SQL command. More to the point, i'm looking to UPDATE an access table field with a certain record ID with the current contents of a cell. I am using Excel 2003.
I would be most thankful you give you permission to marry my daughter.
View 4 Replies
View Related
Jul 20, 2012
How I can directly write info from an external application to an Excel sheet
Actually, I'm using a special dll collection to do it, but I would need to buy the 64 version soon. Problem is I use only one function of the entire collection so I want to look on how to create it my self. Basically, it took data from my charting software and write directly to my Excel Worksheet.Cell
View 3 Replies
View Related
Dec 11, 2012
I've created a User Form to input data on a dashboard where you can select a date from a dynamic list of dates. The list of dates is calculated using:
Code:
=(TODAY())-WEEKDAY((TODAY()),1)+2
The other dates are based on this date -7.
The User Form code:
Code:
Private Sub CommandButton1_Click()
Dim emptyRow As Long
'Make Sheet30 Active
[Code]....
This works perfectly for any date except dates from December. 3/12/12 (3rd Dec) turns to 12/3/12 (12th Mar) when it's copied to the cell. The same happens for 10/12/12 - becomes 12th October instead of 10th December.
View 6 Replies
View Related
Sep 23, 2013
Excel 2003
On one of our computers at work, Excel is acting especially strange. The conditional formatting in Excel on one of our computers is not working. In addition, we cannot fill a cell with any color or change the color of the writing. We can click a color for the letters and type it in, but immediately after another cell is highlighted, the writing goes black again. When we try to highlight multiple cells with the cursor, the cells are black instead of the normal color. This happens to not just spreadsheets that are new, but existing spreadsheets on our shared drive from only this one computer as well. No other computers are affected this way. All other computers show the spreadsheets fine and do not have any functionality issues.
View 5 Replies
View Related
Aug 11, 2009
I have a spreadsheet that will contain about 5-15 rows with a letter "S" in the column. If this letter S appears in the column, I need its entire row to change font color to RED and then change that row's value in column L to a negative number. is there any easy way to do this?
View 14 Replies
View Related
May 14, 2014
Basically, what I'm dealing with is an inventory system. When a cell value reaches below a certain quantity, we have a cell light up with the word "YES" (under the "re-order" column). What I'd like to do is have a macro that checks to see if that cell is populated with "YES" and if it is, to run another macro (which I already have written) that sends out an email notifying us of the need to re-order.
How it would work: The person pulling out the inventory would fill out this form and click "Submit"
submitbutton.jpg
I would then have a "call" code tied to the "Submit" button that when clicked, would run the macro to check cell population and send out the email. The email code is already written and works flawlessly on it's own. I just cant seem to figure out how to write a macro that checks for cell value and then runs it (or not) based on that.
View 14 Replies
View Related
Nov 13, 2012
I have a table in which some of the ranges have to be set to "0" (write "0" inside, not delete) when I click on a button. All the other cells expect these ranges are locked. For now I use the very long way, with the following VBA Code:
Range("E7").Select
ActiveCell.FormulaR1C1 = "0"
Selection.AutoFill Destination:=Range("E7:E21"), Type:=xlFillValues
[Code]....
There are more columns for which I have to do that, and it goes until row 500+ .. I used "Register Macro" to find out this code, that's why I guess it's obselete.
Is there any way I can do it, at least write all the ranges I have to fill with "0" next to each other instead of every time selecting, then inserting 0, then autofill the rang with...?
View 9 Replies
View Related
Dec 15, 2006
I have a list of items in a pivot table where each item has a date. I want to see how many items occur for each month. I am trying to use the COUNTIF formula, but I'm having trouble figuring out how to write the criteria for the dates.
How do I write the criteria part to include the entire month?
View 9 Replies
View Related
Jul 3, 2007
i have an report in which i need to delete the entire row if the column contains values more than 250K, but the chanllenge here is; if any of the cells in the column contains a formula then the macro should not delete the row.....
View 9 Replies
View Related
Sep 25, 2008
if I have another instance of word open my macro will not work correctly. I am at a loss on how to figure this out. Also some times I get the error of virtual machine is not available when getting activedocument.name.
Sub TestTemp()
Application.ScreenUpdating = False
Dim bname as string
bname = Range("B6").Value
Dim WdApp As Object, WdDoc As Object
Set WdApp = CreateObject("Word.Application")
WdApp.Documents.Add "C:TemplatesTest Letter1.dot"
Application.Visible = True
WdApp.Visible = True
AModDoc = ActiveDocument.Name
Documents(AModDoc).Bookmarks("Line1").Range.InsertBefore bname
Application.ScreenUpdating = True
End Sub
View 9 Replies
View Related
Oct 27, 2008
in writing a subroutine that needs to ask the user
1) tax file number
2) Income
3) tax withheld
It then needs to use a function that i already made called 'incometax' that calculates 'taxpayable' and use that to calculate taxreturn (difference between 'taxpayable' and 'taxwithheld').
I then need it to output like this in a message box
Estimate for tax file number: .....
Created on ......
Total income: ......
Tax witheld: .......
Tax payable: ......Tax return: .......
View 9 Replies
View Related
Nov 15, 2008
The following code is supposed to write values from one file into another file - depending on the value of Current_Rider_Name. However, although the code runs and values are being picked up (this is checked through the line that is being commented out).
However nothing is being written to the file. Can anybody point me in the right direction? ...
View 9 Replies
View Related
Aug 16, 2009
way to write your own IRR function using VBA.
Say if I call it Function MYIRR(cfs,per). Where cashflows occur in the periods specified..
i.e
Periods: 0 1 3 4 6
Cashflows: -1000 300 500 100 200
I'm having trouble making sure the initial cash outlay and then cash inflows assumptions hold (problem with the -/+ sign).
I've been told by a friend to try and use abs() function, 'For..Next' loop construct inside a 'Do...While' loop.
View 9 Replies
View Related
May 2, 2007
I am trying to write a UDF that will go like this:
IF A1 is Purple then B1=A1 Else B1=A2.
This is what I have written so far and I cannot figure out how to get it to work:
Function SumIfPurple( Range As Variant, Range1, Range2)
Dim SumAnswer
If Range.Interior.ColorIndex = 39 Then
Range1 = SumAnswer
Else: Range2 = SumAnswer
End If
SumIfPurple = SumAnswer
End Function
View 7 Replies
View Related
Apr 22, 2013
I'm trying to write a word or more but i want it to be in different cell.
Like: this sentence "Excel Program" write it in cell a1 but it slip to the cell a2. (so in cell a1 adn a2 this sentence).
View 4 Replies
View Related
Nov 5, 2007
I have Asset Class in Column I and if it is 364A-EL or 365A-EL or 368A-EL or 368B-EL or 369A-EL or 371A-EL or 371B-EL or 373A-EL or 397C-EL then 'POLES' assigned in to Owner Class (Column J).
If Asset Class is 366A-EL or 367A-EL or 367B-EL or 368C-EL or 369B-EL or 371C-EL or 373B-EL then assign UGCBL to Owner Class.
Should we write the macro or can it be accomplished by any Excel Function?
View 11 Replies
View Related
Oct 16, 2009
I'm trying to use code to write the numbers 1 to 100 in 10 rows of 10
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16......................
So far i have the following which works:
View 4 Replies
View Related
Nov 17, 2009
I run the macro on a currently open workbook (name could be anything) and open another workbook (name known) and step through the sheets copying various blocks of data across to the first workbook. I need to Activate the 2 workbooks alternatively as I move data back and forth and move from sheet to sheet. What I can't work out is how to determine in code what the "unknown" workbook name is so that I can make sure I activate the right workbook in the code.
I tried Activating the workbook with the "unknown" name and setting a variable = ActiveWorkbook.Name. However the value of this variable changes during the code run when you activate the other book. Is there any way to collect this value and "freeze" it so it won't change as the code runs? At the moment I have got round it by ensuring the "unknown" book is the only one open before I start and refer to it as Workbooks(1) in the code.
View 2 Replies
View Related