I want to include Colon Punctuation ":" in my sheet name, however the api recognition the ":" as range definition which causes problems.
I tried to skip the ":" like this : "/:" but it didn't work.
for example :
2019-07-28 22:36 B2C2!A:V
will not work, however if i replace that ":"
2019-07-28 22#36 B2C2
it works normally
When it doesn't work, you'll get a message saying that the range you've selected is wrong.
Quote the sheet name: '2019-07-28 22:36 B2C2'!A:V . This is what you must do when working within the actual Sheets application as well, when the sheet name contains non-alphanumeric characters.
Related
I've Excel sheet that has few text columns. These text columns are Email Messages. The data from this sheet will be used to send mails.
There data looks fine in Excel but when the message is copied to the Email body quotes are appearing in the beginning and end of the message.
I researched online and found out that these are unwanted characters. I tried removing the " using following formula.
=SUBSTITUTE(SUBSTITUTE(CLEAN(K1),CHAR(127),""),CHAR(160),"")
However the problem is that there are multiple columns with this problem so this method is not very feasible option for me. Also another problem is that after this the cell loses the formatting.
Please help me resolve this, I'm looking for a Find and Replace method if possible. Worst case scenario would be a macro.
Thanks in advance.
Cells.Replace What:=Chr(127), Replacement:=vbNullString
Cells.Replace What:=Chr(160), Replacement:=vbNullString
Your cells in your excel sheet contains multiple lines of data within a data, which means all lines in the cell are entered with carriage return. (Enter Key)
If you copy and paste such cells to a txt file, you will get the text within a " ". The " " are not actually quotes, but text with carriage return.
Just use the formula and let me know if it works,
=SUBSTITUTE(A1,CHAR(10)," ")
I have pasted text in cell A1 that may look like this:
"Vanguard - Total Market - Composite" or "Vanguard - Total Market - Commingled"
I want to cut off the " - Composite" or " - Commingled" and return the rest in cell B1. Currently I'm using this formula in B1:
=LEFT(A1,FIND(" - Composite",A1)-1)
However, I can't figure out how to look for multiple terms (i.e. Composite or Commingled). Is there a formula that could accomplish this? If not, how could I do it in VBA?
Thanks for the help!
If I understand correctly, you're simply looking to strip everything past the second occurrence of -, i.e. returning the trimmed (extra whitespace removed) text left of the first - character. Adapting this solution to locate the last word in the string, this would be it:
=TRIM(SUBSTITUTE(LEFT(A1,LEN(A1)-LEN(MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))+1,LEN(A1)))),"-","",2))
This formula will work with or without the spaces around the -, and regardless of what follows:
If even spacing is important, you can wrap it with SUBSTITUTE functions:
=SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(LEFT(A1,LEN(A1)-LEN(MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"-",""))))+1,LEN(A1)))),"-","",2)),"-"," - ")," "," ")
And now you have clean, identically-formatted output for all cases:
I've made this formula that will work with many possibilities as long you fill the possibilities range, not needing to change the formula when there's a new one. Here it is:
=LEFT(A2,FIND(INDIRECT(ADDRESS(SUMPRODUCT((--ISNUMBER(SEARCH(Possibilities,A2)))*ROW(Possibilities)),SUMPRODUCT((--ISNUMBER(SEARCH(Possibilities,A2)))*COLUMN(Possibilities)))),A2)-1)
You can use the SUBSTITUTE function and chain multiple calls:
=SUBSTITUTE(SUBSTITUTE(A1," - Composite", ""), " - Commingled", "")
I'm trying to use a macro to insert an equation into a cell. The equation works fine if I copy it in myself but I need to copy it to 6000 cells in each or four worksheets. This question seems pretty common, but the usual answer of replace ";" with "," doesn't apply. The first line catches error 1004.
Range("J1").FormulaLocal = "=IF(ISERROR(F1),"",IF(ISTEXT(F1),"",F1))"
Range("J1:J6000").FillDown
I also tried using .formulaLocal but that doesn't seem to help.
You need to use double quotes to leave one quote:
Range("J1").FormulaLocal = "=IF(ISERROR(F1),"""",IF(ISTEXT(F1),"""",F1))"
I use this to change the combox value in string type and paste on cells.
cells(i,1)=Cstr(combox1.value)
On Excel column A ,I have set the datatype as String .
For example , I input 017``123 098 065
However , i find that the exact value put on cells(i,1) is '017 '098 '056 123 .
The code starting with 0 contains ' at the beginning .
* Any way to improve my code without appearing the ' on exact cells ,for those codes starting with 0 *
The ' is probably a formatting character, which is a hangover from Lotus 1-2-3 where we used a leading ' to signify left-aligned and a leading " to signify right-aligned. (I think I remember that correctly.)
If it is just the formatting character (if it is, it won't be included in the character count returned by LEN) then you can safely just ignore it.
If you want to get rid of it for aesthetic reasons, you will need to delete the current contents of the cell, format the cell as General format, then format the cell as Text format, then insert new values into the cell.
Note: You can't just format the cell as Text, delete the contents, then insert a new value. The ' will still appear in that situation. The step to change it to General format, if it isn't already in that format, is important! (Maybe setting it to some other non-Text format will work just as well as setting it to General, but I know that General will work.)
Luckily, a .Clear will delete the contents of the cell and set the format back to General, so programatically we can do two things at once.
I therefore believe the following code should do what you want:
Cells(i, 1).Clear
Cells(i, 1).NumberFormat = "#"
Cells(i, 1).Value = combox1.Value
The first line is there simply to get rid of the issue that currently exists. If you were working with a completely new workbook, it wouldn't be needed.
convert the cell's number format to Text before setting numeric values.
cells(i,1).NumberFormat = "#"
cells(i,1)=combox1.value
Hello Stackoverflow friends,
I am struggling for 1 hour with a formula I would like to insert via VBA:
Formula = "=IFERROR(VLOOKUP(Q" & j & ";Table1[#All];2;FALSE);"""")"
ThisWorkbook.Worksheets("Sheet1").Cells(j, "AE").FormulaArray = Formula
I get the following error message:
Run-time error '1004' - Application-defined or object-definied error
Is there an issue with the brackets or double quotes?
Thanks!
Replace the semicolons with commas:
Formula = "=IFERROR(VLOOKUP(Q" & j & ",Table1[#All],2,FALSE),"""")"
OpenOffice uses semicolons to separate function parameters, Excel normally uses commas, and always uses commas when setting formulas in the above fashion.
When programming in any lanugage also in VBA - better not tied up user to specific regional settings or specific excel version.
So instead of this:
Formula = "=IFERROR(VLOOKUP(Q" & j & ";Table1[#All];2;FALSE);"""")"
ThisWorkbook.Worksheets("Sheet1").Cells(j, "AE").FormulaArray = Formula
Better use this approach, when you determine exact user environment:
s = Application.International(xlListSeparator)
Formula = "=IFERROR(VLOOKUP(Q" & j & s +"Table1[#All]" + s + "2" + s + "FALSE)" + s + """"")"
ThisWorkbook.Worksheets("Sheet1").Cells(j, "AE").FormulaArray = Formula
p.s. I didn't checked the formula for the brackets etc. but just indicating the correct usage of list separator, and how to insert formulas with VBA code within cells in correct way.
As well, as previous post says - excel probably change the formula automatically when you open it. However excel do not change VBA code automatically, so be aware and pay attention to proper code in VBA.
Depending on the regional settings, the list separator (which is also used to separate parameters in functions) is either the semicolon or the comma. This applies when typing a formula into a cell.
Excel dynamically adjusts the list separator (and function names) according to the regional settings of the current computer when a file is opened.
So, if a user with German regional setting, which have the list separator ; saves a file, then a user with US regional settings and a list separator , opens the same file, Excel will adjust the German list separators in the formulas automatically.
When writing VBA, though, you will always need to use the US-English conventions for the list separator, which is the comma.