I can't seem to figure out how to concatenate an asterisk into a vba formula or a string for that matter.
it just always results in an error.
You need to do the concatenation outside the sumproduct formula. This should work:
TryOutputModelTab.Range("F2").Formula = "=SUMPRODUCT(D$2:D$" & LastUsedRowOnOutputModelTabA & ") & ""*"""
Related
I have three formulas
(1) =(B2:B&"."&substitute(substitute(lower(C2:C),"jalan","jln")," ",""))
(2) =COUNTIF('Payment Configuration'!A:A,A2:A) + COUNTIF('Payment Configuration'!E:E,A2:A)
(3) = =IF(ISBLANK(B:B),,B:B & ", " & UPPER(C:C) & ", BANDAR PUTERI KLANG")
Guys, I want to dragging this formula's until the last row without using Array formula because if I convert this formulas into array somehow it is not working in my web app (which is written in Google App Script). So anyone can help me with this formulas. Thanks in advance
If you want them to only work on a line at a time you need to trim the range to one row only:
=(B2&"."&substitute(substitute(lower(C2),"jalan","jln")," ",""))
=COUNTIF('Payment Configuration'!A:A,A2) + COUNTIF('Payment Configuration'!E:E,A2)
=IF(ISBLANK(B2),,B2 & ", " & UPPER(C2) & ", BANDAR PUTERI KLANG")
With the first two, you could add ISBLANK like your 3rd example.
I have excel sheet containing column with values such as
BANDHANBNK
SRF
SRTRANSFIN
L&TFH
IBULHSGFIN
FEDERALBNK
PNB
PEL
VOLTAS
I want to create hyperlink for each of this, url can be created as
https://in.tradingview.com/chart/?symbol=NSE:ACC1!
so I need to concatenate
https://in.tradingview.com/chart/?symbol=NSE: + cell value + 1!
doing this manually is too much work, is there any simpler way to do this?
one more thing is if cell value contains & or - it should be converted to underscore.
Use following formula. Here simply concatenating cell value with URL then concatenate 1!. Use Hyperlink() formula to make hyperlink.
=HYPERLINK("https://in.tradingview.com/chart/?symbol=NSE:" & A1 & "1!",A1)
To replace & and - by underscore _ use below SUBSTITUTE() formula.
=SUBSTITUTE(SUBSTITUTE(A1,"&","_"),"-","_")
this worked for me.
=HYPERLINK("https://in.tradingview.com/chart/?symbol=NSE:" & SUBSTITUTE(SUBSTITUTE(E2,"&","_"),"-","_") & "1!",E2)
I need to use a vlookup function where I would get all the arguments from different functions and use them here.
Eg: ActiveCell.Formula= “=VLOOKUP(B2, ‘sheet 2’!$A:$I, 4, FALSE)
I would like to write this as:
VLOOKUP(element, f_range, col_num, true_false)
Currently, I only want the column to be dynamic, but in the future, I would require all these to be dynamic.
When you write a formula you do it between "" because its a literal string which will be outputed to an excel cell. To use variables you need to write them out of the quotes.
i.e. "=VLOOKUP(" & element & "," & f_range & "," & col_num & "," true_false & ")"
Don't forget the commas because they are aswell on the formula. & is a concatenate operator, it will put together everything you are joining with it.
There is another way if you are willing to have values instead the formulas on your cells:
ActiveCell.Value = Application.VLOOKUP(element, f_range, col_num, true_false)
This will calculate the value and put it to your cell. No need to concatenate anything, just give it the parameters as variables.
the following throws an error. I tried to escape the strings, but no luck. How do I have to correctly enter the following formula into the field:
wrkSheet.Range("I6").FormulaR1C1 = "=IF(AND(G6=TRUE;H6=TRUE);""Correction Transaction"";IF(AND(G6=TRUE;H6=FALSE);""Execution Correction"";IF(AND(G6=FALSE;H6=TRUE);""Reverse Correction"";""Counter Booking"")))"
change FormulaR1C1 to Formula, since you are using "A1" notation (e.g.: G6, H6)
change ";" to ",", since ";" is not a valid formula separator in VBA
Range("I6").Formula = "=IF(AND(G6=TRUE,H6=TRUE),""Correction Transaction"",IF(AND(G6=TRUE,H6=FALSE),""Execution Correction"",IF(AND(G6=FALSE,H6=TRUE),""Reverse Correction"",""Counter Booking"")))"
Is it possible to have SUMPRODUCT to sum values "if cells within range contain a certain piece of string"?
PS: it has to be a string since letters are actually names and words from the actual report.
Maybe a combination between SUMPRODUCT and SEARCH, but I couldn't get it to work.
With only one column use SUMIF() with a wildcard:
=SUMIF(A:A,"*" & D2 & "*",B:B)
If you are worried about false positive as #YowE3k stated:
a SUMIF(A:A,"*BERT*",B:B) will count the values for Bert, Robert, and Roberta.
You will need to limit the reference to only the data set and use SUMPRODUCT:
=SUMPRODUCT(ISNUMBER(SEARCH(" " & D2 & " "," " & $A$2:$A$6 & " "))*$B$2:$B$6)