Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


Quotes In A VBA String For A Cell Formula

I'm trying to put a formula into a group of cells with VBA. However, the formula requires quotation marks in it...e.g.,

the formula in the cell should be... = "STR - " & intRow

where intRow will insert a designated integer. My problem is the quotes for the string part....I can't get the VBA code (tried both setting a string variable and using range.value =) to keep the needed quotes.

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Find Text String Value Between Quotes
Formulae Solution prefered if possible--

Is it possible to extract the two text strings between the quotes, placing them in Col. C & D respectively, e.g.
Application.WorksheetFunction.Substitute(c.Formula, " ANTI ", " ANTI-HERO ")
Application.WorksheetFunction.Substitute(c.Formula, "SEC9", "SECTOR 9")
Application.WorksheetFunction.Substitute(c.Formula, "LNGBRDC", "LONGBOARD COMPLETE")

--Col. C---------------Col.D
SEC9--------------- SECTOR 9

There are three types of scenarios-
1) Values enclosed in quotes that begin and end w/ spaces:
Application.WorksheetFunction.Substitute(c.Formula, " ANTI ", " ANTI-HERO ")

2) Values enclosed in quotes that does not contain a leading space or trailing space:
Application.WorksheetFunction.Substitute(c.Formula, "SEC9", "SECTOR 9")

3) Values enclosed in quotes that have a space between itself:
Application.WorksheetFunction.Substitute(c.Formula, "LNGBRDC", "LONGBOARD COMPLETE")

View Replies!   View Related
Copy Text, With Quotes, Without Quotes
I'm trying to set up a macro to be assigned to a button to copy the text in a cell into an application which uses similar text capabilities to Notepad.

The simple macro of:


... results in the text of the cell being copied to the clipboard with quotation marks before and after the text. I can manually enter the cell, select the text, the copy it... but this process can not be recorded in a macro - I can edit the cell and copy the text but when leaving the cell it gives the error "unable to record".

Is there any way I can copy the text to the clipboard without getting these quotes?

View Replies!   View Related
Formula With Quotes Not Recording
Some of the below address was removed, how would this formula be written in VBA? When I try to record this formula excel tells me unable to record, probably due to all the & within the address itself ...

View Replies!   View Related
Quotes/Quotation Marks In Formula Macro Code
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

View Replies!   View Related
Formula Requires Parameter In Quotes, Indirect Doesn't Work
I've been given a formula to use (embedded in an add-in that is password-protected). One of the parameters REQUIRES quotes.

The formula goes like this: =MYFORMULA(1,2,3,"ABC")

If I put ABC in a cell (say C5) and use the formula =MYFORMULA(1,2,3,INDIRECT(C5)), the formula doesn't work.

If I put "ABC" in cell C5, the indirect function still work make the function work.

Even if I have ABC in cell C5 and use =MYFORMULA(1,2,3,""""&C5&"""") or =MYFORMULA(1,2,3,""""&INDIRECT(C5)&""""), these won't work.

I wish I could just change the UDF behind this, but that isn't possible.

View Replies!   View Related
Cell Address Without Quotes
I have a table of data which contains golf form for the last four years. For simplicity I have split this data into four separate worksheets representing each year, 2005, 2006, 2007 and 2008. These tables contain the data, Player Name, Event Name and Finishing Position. I have a results worksheet which contains a table which has the Player Name in the rows. To the left of the Player Name I have three columns which represent the Finishing Position in a particular event for the last three years. To the right of the Player Name I have their finishing position for all events played this current year.

For the historical event form, i.e. 2005, 2006 and 2007 I would need a formulae which looks up the corresponding year worksheet and looks up the Player Name and Event Name and returns the Finishing Positon. For the current year form I need the formulae to lookup the Player Name and the Event Name in the 2008 data worksheet and return the relevant Finishing Position.

Auto Merged Post Until 24 Hrs Passes;I have attached a file which will hopefully make things clearer. In the worksheet 'Form' I would like the columns A, B and C completed for the players form from this weeks event, in my example "Colonial", for the previous three years. I therefore need a formulae to go to Worksheet '2007' and lookup Aaron Baddeley, Colonial and return the result in the column entitled 'FP'.
For the columns E, F, G and H, I require a formulae that looks up the Worksheet '2008', Aaron Baddeley, and then the Event Name from Row 5 on the 'Form' worksheet to return Aaron Baddeley's result from the various tournaments held in 2008.

View Replies!   View Related
VBA Stop If Active Cell Contains Text String
how to create VBA code to stop macro if activecell contains text string?

I have code like this

Sub halo()
If application.istext(activecell.value) = True Then
exit Sub
End If
End Sub

View Replies!   View Related
String To Cell (Formula)
I'm having problems with small macro I'm writing.. I'm very close to finishing it but I'm stuck at the end by an extremely small/basic error. What I wan't to do is take a Formula that was generated in a loop and is stored in a string and to output it to a cell on my worksheet as a working formula...

View Replies!   View Related
VBA Slow To Assign A Null String To A Cell - On One Computer Only
I have a VBA program which is running very slowly on one of my computers, but none of the others.

Here's a piece of code which illustrates the problem, which is that assigning a null string to a cell is very slow.

Option Explicit
Public Sub test()
Dim objSh As Worksheet
Dim I As Integer

Set objSh = Worksheets("Sheet1")
MsgBox "test1"
For I = 1 To 1000
objSh.Cells(1, 1) = ""
MsgBox "test2"
For I = 1 To 1000
objSh.Cells(1, 1) = " "
MsgBox "done"
End Sub

If I change this to assign a space instead it is very fast (about 1,000 times faster).

This slow machine is not normally slow; an ACER Aspire 9410Z with 2GB RAM, running Vista Ultimate.

Other machines run this code OK on a mix of Windows XP, 2000 and Vista Business. with Excel 2003, 2000 and 2007.

Ultimate seems to be the only unique factor of the machine where it runs slowly.

View Replies!   View Related
Vlookup Formula In VBA - Object Error (input A Formula Into A Cell)
I'm having some trouble trying to get excel to input a formula into a cell. I'm still a novice at VBA right now, so I don't think my problem will be too much of a brain buster.

I want a formula in Cell A6 (and I already know it correctly works) in this format: =E6&VLOOKUP(I6,'FA-Fund Data'!B$1:C$2000,2,FALSE)&J6

View Replies!   View Related
Convert A String To A "real" String (vba)
How can any string valid for the name of a workbook be converted to a string correctly recognized by Application.Run? Sometimes a string is not really recognized as a string. See for example: .....

View Replies!   View Related
In Cell A8 I Have "text" W/o Quotes
I have A UDF now in my Personal.xls file

It appears that I must reference as so, in order to acheive my goal


Can this be shortened to soehow exclude the Personal.xls! portion?

View Replies!   View Related
Copying Formula From Vba To Cell
I want to copy the following function via vba to a number of cells

=countif(i10:ah10,"does not comply")

i basically want row to do a a comparison from i10 to ah10, row 11 to do a comparison from i11 to ah11 and so on.

i tried this as a first step
Workbooks(WorkBookFileName).Worksheets(TabID).Cells(m, fc + 8 + 1).formula = COUNTIF(I97:AH97,"does not comply")

but i got the error

"compile error: expected: list seperator or)

and i tried this one

Workbooks(WorkBookFileName).Worksheets(TabID).Cells(m, fc + 8 + 1).text = "=COUNTIF(I97:AH97,"does not comply")"

and got the error compile error: expected : end of statement

i read some place to ensure that the reference is copied, one can use the following
wks.Cells(i + 13, 7).FormulaR1C1 = wks.Cells(i, 3).FormulaR1C1
but cant get through the first step, where i actually use vba to make the first entry

View Replies!   View Related
Using Cell Values In A Formula With VBA
how to use a cell value in a formula with VBA.

For example, I have the following
FinalRow = Cells(65536, 1).End(xlUp).Row
CYGP = Cells(Final Row, 11).Column
Cells(FinalRow + 2, CYGP).Select

I now need to be able to use the value that's located in the selected cell elsewhere in the spreadsheet. I've tried the following:

ActiveCell.FormulaR1C1 = "=R[FinalRow]C[CYGP]

This was an attempt to put the value that's in Cells(FinalRow, CYGP) into my active cell, but it's not working...

View Replies!   View Related
Edit Cell Formula Using VBA
I've got this small (?) problem here. In a range of about 150 rows and 30 colums, I have to edit the cell formula, i.e. add something to the existing formula. For instance, in all the cells in column C I need to add " + D9" to the existing formula, in all the cells of column D I have to add " + E9". Is there a way to do this in VBA ? I would already happy to do it column by column, but I'm really reluctant to edit 4500 cells manually.

View Replies!   View Related
VBA - Changing The Value Of A Cell From A Formula To A Value
I currently have some code in VBA that for each line creates a vlookup and a second one that takes the left part of a cell, depending on where a "/" is located in the cell as below:

For i = 2 To FinalRow
Cells(i, FinalCol + 1).Formula = "=VLOOKUP($A" & i & ",LookupList,3,FALSE)"
Cells(i, FinalCol + 2).Formula = "=LEFT($F" & i & ",FIND(""/""," & "$F" & i & ",1)-1)"
Next i
The issue I am finding is that running the 2 formulas for 4000 rows is taking approx 5 mins. The end user doesn't need to see a lookup, the value stored from the result would be fine.

is this possible. So that the value of the cell is a result of a formula I have created?

View Replies!   View Related
Putting Formula In Cell With VBA
I tried to put the following formula into a cell using vba, but I received alot of errors. here is the formula I am trying to put into a certain cell and I will use a variable to replace the row number in the formula

=IF(AD323<>"Open","",IF(OR(AND($AI323=TODAY(),$AJ323<>"Done"),AND($AN323=TODAY(),$AO323<>"Done"),AND ($AS323=TODAY(),$AT323<>"Done")),"Yes",""))

View Replies!   View Related
Use Cell Color In Formula Without VBA
Is it possible to reference a cell's colour in a formula within a spreadsheet - without using VBA? i.e If Cell A1 has a fill colour of yellow, can I have a formula in cell A2 that says If Cell A1 fill colour = Yellow, result = 1 etc. I know this can be done in VBA, and I have done that, but just wondered if possible this way.

View Replies!   View Related
Edit/change A Formula In A Cell Using VBA
How to edit a formula in a cell using vba code.
For example, the cell A1 in sheet "sheet1" contains formula "=sum(Sheet2!B1+Sheet3!B1)" and I would like to use VBA to edit/change it to "=sum(Sheet2!B1+Sheet3!B1+Sheet4!B1+Sheet5!B1)" and so on

View Replies!   View Related
Vba Code To Insert A Formula To Certain Cell
I try to put a formula to a certain cell using this code, but I get application defined or object defined error:

HTML Selection.Cells(1).Offset(0, 5).Formula = "=INDEX(range1;MATCH(""D""&C13;range2;0);MATCH(""S""&D13;range3;0))"

The weird thing is, that if I type the same formula itself to a cell, it works, so the problem shouldn't be with the formula:

HTML =INDEX(range1;MATCH("D"&C13;range2;0);MATCH("S"&D13;range3;0))

On the other hand I tried to replace the formula in my VBA code with simpler one, like this one and that worked aswell:

HTML Selection.Cells(1).Offset(0, 5).Formula = "=a1+a2"

View Replies!   View Related
Insert Formula In Cell From VBA With False
I want to make changes to a cell's formula when a combobox option is clicked,
I can make the changes using sheet1.cells(x,y) = "=WHATEVER(bla,bla,false)"
The problem is that when I run the program and make a change in the combobox, false is written as 'false' in the cells formula, which drives it into not working and displays ####### as the cells result.

View Replies!   View Related
VBA Test To Determine If Cell Has A Formula Or Value
I need to take a specific action when a cell has an actual formula in it versus when it just has a "value". Is there a procedure or command which will allow me to identify if a certain cell has a "formula" (like =sum(a1: a5) ) or just a value.

View Replies!   View Related
Vb Code Using Quotes
I have a formula that i want to give a cell using vb. The problem im having is that the quotes give me a compile error in the mm/dd/yy part. What is the way around this? The following code is what i need vb to put into the cell.

View Replies!   View Related
Insert Formula Based On Cell Entry Using Vba
i'm sure this can be done but i cant get an angle on the method. i want to use VBA to put a formula into cell G3 based on the users entry in cell D3 so, for example the user enters M in cell D3 and the VBA code puts the formula "if D3="M",A3,0"into cell G3

i know i could use a formula in the cell but i want it to work with multiple entries so i figure VBA is the way to go.

View Replies!   View Related
Vba Variable To Replace Cell Address In A Formula
when i am doing the coding

may i know if there is a way to replace the cell address $A9 below: ...

View Replies!   View Related
VBA To Add Sheet Reference Formula To Cell
Im trying to copy a formula to a cell via VBA.

ActiveCell.FormulaR1C1 = "=Sheet1!A3"

Ive tried all sorts of ', ", &, combinations, I cannot find it.

View Replies!   View Related
Triple Quotes In Text
I'm running the following to put quotes around data in a workbook:

Sub test()
For Each s In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
s.Value = """" & Format(s.Value, "00000000") & """"
For Each s In Range("B1:B" & Cells(Rows.Count, 1).End(xlUp).Row)
s.Value = """" & Format(s.Value, "####") & """"
End Sub

And exporting as a CSV file for loading into another program. The problem is everything looks OK in Excel, but when I open the file in Notepad to check the output, the quotes are all triple. How can I get only single quotes around the data?

View Replies!   View Related
Yahoo Quotes Into Spreadsheet
I have a spreadsheet with several stock symbols in a1:a25

I want to look up the last price and put it into b1:b25 for each stock in a.

I have tried all aspects of symtol"&f=l1 as a query but can not get it to work without specifying the symbol in the url for each symbol.

I am assuming that I need a macro of query that can look up the range to provide the prices.

The reason is that the list of symbols changes daily and I need to look them up daily.

View Replies!   View Related
Export First Column With Quotes
It exports a sheet to a text file with quotes and commas as delimiters. What I need is to only add quotes to the first selected column.

View Replies!   View Related
Commas & Quotes
I have a rather large file that I need to convert. Right now, there are about 3 columns and over 4500 rows. What I need to do is have everything separated by quotes and commas. I have a macro to somewhat do this, but it is putting an extra comma in front of everything. My question is this:

Is there a way to take out a comma that is in front of every entry?


Is there another macro that will separate the columns with a single quote and comma, like below:


View Replies!   View Related
VBA String Manipulation
I need to be able to take someones name which is in a single cell in the format "First Middle Last" (could be more than one middle name) and then split it up so that it fits the following format:

Last name (must be 50 characters)
Middle name (must be 15 characters)
First Name (must be 15 characters)

I'm unsure on the right combination of operators to use to variably concatenate strings in this way. I'm confident I can figure out how to add the white spaces after a name to make it fit the character requirement but I don't know how to split the initial name up into it's 3 parts. Names longer than the character requirement will just be truncated.

View Replies!   View Related
VBA - Search For A String
A1:A2000 (or the wole column) will have the following:

Black Total
Grey Total
Total Grey Print
Blue Total Print
and so on.

Each cell will contain the word "Total". In B1:B2000 ( or the whole column) I would like to remove the word total from the column A. Example:

B1 should only contain Black (instead of Black Total)
B3 should only contain Grey Print
B4 should only contain Blue Print

View Replies!   View Related
Vba To Get The Numeric Value From Given String
IDMacro Out Put

I ahve a sheet having two column one is "ID" and other is "Macro Out Put" as shown above , is that possible with VBA code that it give the same result as i shown above in column "Macro Out Put". for reference i also attch the file

View Replies!   View Related
Inserting Quotes Into A CSV File
I have a csv file that needs to be formatted and then saved as a csv file, and i have written code to do this but i need all of the values in the csv file to have one set of double quotes but at present all of the values do not have any quotes, how can i go about this.

Here is an example of the formatted csv file ....

View Replies!   View Related
Removing Quotes From A Sequential File
I am using the following code to output the contents of my listbox (lstMessage) to a text file called messagelog.txt...

View Replies!   View Related
VBA; Find String And Copy
I would like to call up a find box, then be able to search several worksheets for a string, to copy and paste the related row to a new worksheet.

I've gotten as far as being able to search for a string and get the row pasted, as long as the string is defined in my macro. Is there a way though to be able to call up a find box first though, and search for the input variable? (alternatively, I can only imagine a separate piece of code for each variable, of which there are many, and I am actually trying to save time.

View Replies!   View Related
Evaluate First Character Of String In VBA
How can I evaluate just the first part of these stirings so I can just do something like Left("Ca",2)?

View Replies!   View Related
Find Value In String Using VBA Macro []
I need to check a certain value in a string


In the list over I want to find nr 2 and 3. Using Instr sorting for 'ap' gives me all the list. How could I use string functions in a VBA macro.

View Replies!   View Related
Use String To Execute Vba Code??
how could I use string to execute VBA. For example

mystring1="for i =1" & " to " & CStr(x)
mystring2="msgbox i"
mystring3 ="next i"

execute mystring1 & mystring2 & mystring1

Like this, I want to combine a VBA CODE string.
And use this string to execute VBA

View Replies!   View Related
String Value Sum Function Vba
I have a Sum function in a cell on a spreadsheet and a bit of code which checks it using an If statement. If the Sum equals 1 (100%) it should do one thing, if not do another. However, if I put in the If statement that the Sum cell value should equal 1, it doesn't work. If I put it should equal "1", it does work. Why?

Example that works:

If Range("LocalBirthTypes").Value <> "1" Then
MsgBox "To use your own data the split between the birth types must total 100%", vbExclamation, "Maternity service planning tool"
Goto Exiting
End If

Example that doesn't work:

If Range("LocalBirthTypes").Value <> 1 Then
MsgBox "To use your own data the split between the birth types must total 100%", vbExclamation, "Maternity service planning tool"
Goto Exiting
End If

View Replies!   View Related
Extracting Text From String Vba
I need to extract the text from a string that is always less the last three digits. For example if A1 is abcdefg I always have to take off "efg" and extract the rest of it to the left but the length of the string can vary. I can be dirty and record a macro where I find the length, subtract 3 and then using the LEFT worksheet function can get my result, but when I come to try to convert that to VBA. What is the VBA equivalent of LEFT worksheet function and how would I go about using LEN in conjuntion with subtracting 3 from it?

View Replies!   View Related
Reformat Date String In Vba
I m trying to use a variable that is declared as a range in a formula. GroupCategory is the name of the sheet its getting the data from. I want to use myRange instead of actually putting in the range. I know there's something wrong where I highlighted in red.

Sub AAmacro()
Dim myRange As range
Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Set myRange = Range(Cells(2, 1), Cells(Lastrow - 1, 1))
Range("L2").Formula = "= SUM(INDEX(GroupCategory '!' & myRange,,MATCH(C1,GroupCategory!$A$1:$ AI$1,0)))"
End Sub

View Replies!   View Related
Adding Formula To Cell Using VBA Which Has "$" In Formula
Problem: This is what i want to show up in a given cell.

View Replies!   View Related
Find The Sum Of The Quotes Based On Each Brand
I'm looking to create a monthly sales report based on brand and month.

I have done it in the past using a load of if statements checking for monthly totals and then adding up the coloumn.

But there must be an easier way.

I have 4 brands. so In january I want to find the sum of the quotes based on each brand.

'A' contains the date
'J' contains the brand - Say A, B C or D
'M' contains the quote value

I want to firstly count the number of enquiries per brand per mont. (these are all entries without a qoute value.

Then I want to count the number of quotes per brand month (these are the entries with a quote value)

The I want to find the total value of the quotes per brand . per month.

View Replies!   View Related
Invert Stock Quotes From Newest To Oldest
I inted to invert stock quotes from newest to oldest but I can't cope with it.

How to invert for example numbers like 2, 10, 3, 15, 1 into the form of 1, 15, 3, 10, 2 ?

View Replies!   View Related
Application.Run - Spaces And Single Quotes
Ok so I know I can run a function in another (open) workbook by doing the following line:

View Replies!   View Related
VBA How To Select Specific Characters From A String
In one column I have different objects separated by a comma. I need to select one of these: 11,20,30,60,61 and copy it into another column. I have used this
For counter = 0 To not_empty_cells

For counter_dep = 1 To 5

position = InStr(1, (Cells(counter + 3, 4)), department(counter_dep))

If position > 0 Then
symbol_dep = Mid(Cells(counter + 3, 4), position, 2)

Cells(counter + 3, 10).Value = symbol_dep
End If

Next counter_dep

Next counter

It works, however, once in the first column there are the following objects: 60,6128,CZ, it takes 61 but it should take 60. Unfortunately, the position of the object can vary, it is not always on the first position.

View Replies!   View Related
Find Number Within A Text String Using VBA
I have a list of English game results with the score and the soccers of the game.

E.g. : [Steinsson 34, Davies 41, Elmander 46; Fuller 91]

As you can see in the excel, what Im trying to do is to find the time i.e which is the numbers in the field and display them seperately onto the cells beside. So what i need is to Find and extract these numbers 34,41,46,91 and paste them just beside cell on the list.

I can use formula but i can only display 1 number, so i think this might require a VBA script.Thanks in advance guys..

View Replies!   View Related
VBA Function - Extract Number(s) In String
My knowledge of functions is pretty limited, or negligible to be honest. I require a function to extract numbers from each cell in a selected range.


cells contain the following data:

cell 1: xxxxxx 45,59
cell 2: x xxxxx xx 6,45,27
cell 3: x xxxx 28

were x represents text

I need to loop through each cell and extract each of the numbers and list them in a separate range. If applied to the above range of cells the function would show the below in the ouput range. Each number in its own cell.


View Replies!   View Related
VBA: Parsing Multiple IP Addresses From A String
I have some code that will parse the FIRST IP address it finds in a string. Could someone help with the code for continuing through the remaining part of the string and parsing out any additional IP addresses it finds and concatenating them with a comma and space (", ")?

There are specific rules for validating a "proper" IP, but for the purposes of my work, I don't need to validate. I found the following code on a google group (thanks Jeff M). All it does is parse the numeric text surrounding the 3 periods that all valid IPv4 addresses contain. For my purposes, it works ....

View Replies!   View Related
Copyright 2005-08, All rights reserved