VBA: get data having hyphen in the begining - excel

When I enter data in excel cell with prefixing hyphen like " 'Data ",it does not get you hyphen when you fetch it in vba, but it`ll be visible in formula bar. How to handle this? I can not change the data. How to get the data displayed in formula bar?
I`m using Range.value to get data.
Please help.
Thanks.

One possibility would be to check for the prefix with Range(myRange).PrefixCharacter and then handle it.

Related

how to store text starting with '+' in excel?

I need to store value like +a1.2.0 in excel cell but after storing it appears as #NAME?
If I double click on it, then only the content appears. If I directly open the excel I should see the content not #NAME?. I am not able to produce it. Any suggestions?
I think this #NAME? appears because of formula it automatically created because of '+' sign before the content.
You may write apostrophe ' before or change the format from General to Text.

Concatenation inside a HYPERLINK formula using email

I have a sheet that concatenates various cell values (from general, text, currency and cell formats) and hard-coded strings to create an email with the mailto, subject and body pre-filled based on cell values. I have had this working but something has now broken but I still don't think there is very much wrong with what I have done.
The error I was getting was #value (error related to data being of the wrong type) but now after some edit that I must have done it now throws #name instead. The data is pulled from a row in a table that has been created from Power Query but I have pasted the code here as A1C1 references so that someone could more easily replicate it on their own version. I will plod away trying to see what I have done to break the formula. I have focused mostly on where quotation marks are but will try solving it in a blank sheet also. It may be that the cell formats are the issue but have been trying to solve this for hours!
Any help greatly appreciated!!
My formula is:
=IF(ISBLANK(U5),"",HYPERLINK("mailto:"&AB5&"?Subject=Approval requested for project file "&LEFT(R5,LEN(R5)-5)&" - "&C5 "&body="Hi " &LEFT(H5,(FIND(" ",H5,1)-1))&", %0d%0a%0d%0aApproval of €"&U5& " for "&LEFT(R5,LEN(R5)-5)&" - "&C5&" has been granted.%0d%0a%0d%0a PO#" &T5& "%0d%0a%0d%0a Kind regards,%0d%0aSiobhán"))
Peter
P.S. I have run this though the 'evaluate formula' wizard and the result just before it fails is below:
Hyperlink formula just before fail

Error when entering table_array with spaces in the name Excel Formula

first my apologies for being a noob with regard to Excel Formulas - I did search and did not find an answer.
I have a spreadsheet that I am trying to modify. I got two spreadsheets from a client, who gave me a working copy and one that he had modified. There is a #REF error in the modified version. If I look at the working copy the formula looks like this.
=VLOOKUP($C$1,'Client Rates'!$A$2:J$228,5,FALSE)
As you can see it has quote marks in the table_array parameter because it does have a space in it. However I cannot enter it this way as it throws an error every time I try. Error is something like this - 'There is a problem with this formula. Not trying to type a formula? ... '
How can I enter the work sheet as a parameter with spaces in the name into the formula?
Did you try F2 to edit formula directly. Then highlight section of formula you wish to change then select the actual data you want evaluated by the formula?
Excel will create the correct string for the sheet and area reference for you.
The problem is you are trying to copy and paste directly from on workbook to another. Copying ctrl-c and pasting ctrl-v from one workbook to another may not have the desired effect. If you copy first to notepad or some other text editor and then paste from that text editor all works fine.

Excel formatting using JXL

I generating a excel sheet using jxl, a number of the columns have data that is
preceeded by a hidden apostrophe. The apostrophe can only be seen when you
click on the cell. I have looked and can't find a post that addresses this.
Can anyone out there tell me how to remove this using jxl or any other.
I've a feeling that the apostrophe indicates to Excel that the data in the cell should be treated as text.
Are you writing your cells to the spreadsheet as the correct types? E.g. jxl.write.Number, jxl.write.Label, jxl.write.DateTime, all of which implement jxl.write.WritableCell.
More information about how you're writing these cells, what data they contain and how it appears in Excel would be useful.

Paste from SQL to Excel... Excel wants to think for me

Group I am pasting data from SQL to Excel and it appears that Excel is trying to read my mind by converting some of my numbers to dates. I.e. one number is 2-2131 and when I paste it to excel it shows Feb-31 even 2-3291 wnats to be Feb-61
STOP IT EXCEL!
This is driving me crazy and I can't seem to find an easy way around this. I tried "paste special" as text and it still formats. I can get it to work if I create a connection and use the query, but I just want to be able to copy-paste data for testing purposes.
Anyone have an easy solution to my headache?
Thanks in advance!
Format the column as text before pasting the text.
Select the cells ahead of time and mark the formatting as Text. (Format->Cells, select "Text" from Categories and click OK). Then paste your data.
Hit F-2 before you paste the code and then it just puts it into one cell.
Highlight the affected row, right click, choose Format Cells..., select Text before you paste the data.
After pasting the sql data to excel, change the date and time format of excel to simple numbers seprated by dashes. That way round even if excel would assume it to be date, it would display the numbers as it is.

Resources