As i failed to convert my excel formula to a vba compatible one, i decided to simply insert the value as follows:
Range("AB3").Formula = "=MID($AA3;FIND(CHAR(134);SUBSTITUTE($AA3;AB$2;CHAR(134);1))+22;FIND(CHAR(134);SUBSTITUTE($AA3;AC$2;CHAR(134);1))-FIND(CHAR(134);SUBSTITUTE($AA3;AB$2;CHAR(134);1))-25)"
Unfortunately it gives me a run-time error 1004, which is weird since if i try remove the first "=" and then adding it manually, the formula works in excel...
Would any of you know what the issue is ?
Thanks in advance
Related
Hello I am facing some issue while running a macro in Excel VBA.
For Each cell In [Data!A2.A65536]
I was using the above code, and was getting type Mismatch error. When I replaced it to
For Each cell In Worksheets("Data").Range("A2:A65536").Cells
the error was gone.
Since I am not well versed in vba, can anyone explain what's the difference in the above snippets? What was the issue due to which the aforementioned issue was happening? and can someone please confirm, if I have correctly replaced the code.
The second one is "best practice" and is the one you should use.
The square brackets is just a shortcut notation for the range property (see Refer to Cells by Using Shortcut Notation) it is actually the same as using the Evaluate Method.
You get an error because you used a dot . instead of : in [Data!A2.A65536] it should be [Data!A2:A65536].
So using [Data!A2:A65536] is the same as Evaluate("Data!A2:A65536"). If possible I would avoid Evaluate or the bracket notation.
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
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.
I did a lot of research on this topic, but could not find a solution.
I created a macro to search for value and put it in the cell.
My program returns me error i.e 1004 which means data not found.
I debugged the program and found that the value, when it was fetched it was "TSK0000000788", but when I incorporated that variable in the VLOOKUP function it changed it to "TSK788".
I also tried to change the format of cell, just to see if it helps, when I changed it to Text, Formula was not working. By default it was set to General only.
Is this error common?
I have tested VLOOKUP function with various formats in the Table, so Long as your Lookup value is ("TSK788") in the function, it works correctly. Please try your function on a new workbook on a new sheet after pasting data on some Text Editor like Note Tab Light or Note pad and the again copying and pasting data to your new worksheet. Please see if the problem still persists.
I am working on some Excel functionality using VB - but I am getting stuck at some examples.
Current version is Excel 2007, using a blank Workbook; I've added in a module and trying a function like the following:
Function Addtwo(a, b)
Addtwo = a + b
End Function
However, I get the error #VALUE! in my cell, when doing Addtwo(5,5). When trying to do Addtwo(B2,B3), Excel tells me my formula is wrong.
Thanks,
The pasted code is okay and works in my Excel 2007.
The only possible problems I can think of:
You forgot to use the equal sign: Addtwo(5,5) instead of =Addtwo(5,5)
Your language settings require a semicolon instead of a comma in the formula, i.e. =Addtwo(5;5) (in the worksheet formula only, not in the VBA code)