Hi All
I am trying to use the TRIM function in VBA but am struggling!
The code which works in excel is:
=TRIM(RIGHT(SUBSTITUTE(N2,"-",REPT(" ",100)),100))
when I try to use the same in VBA, I get a compile error: expected end of statement
I assume that this is because of the " within the code (so VBA thinks code is finished?) so I tried to get round this by creating the formula as a string as follows:
SupplierNoFormula = "=TRIM(RIGHT(SUBSTITUTE(N2," & """ & "-" & """ & ",REPT(" & """ & " " & """ & ",100)),100))" - which also doesn't work!!!
what I basically have is a list in one column of supplier name and number (separated by '-' ie A SUPPLIER-OR12_12345) and I need to extract the supplier number (OR12_12345) to enable me to do a lookup to another report
Any help would be greatly appreciated
Thanks in advance!
Janet
I am trying to use the TRIM function in VBA but am struggling!
The code which works in excel is:
=TRIM(RIGHT(SUBSTITUTE(N2,"-",REPT(" ",100)),100))
when I try to use the same in VBA, I get a compile error: expected end of statement
I assume that this is because of the " within the code (so VBA thinks code is finished?) so I tried to get round this by creating the formula as a string as follows:
SupplierNoFormula = "=TRIM(RIGHT(SUBSTITUTE(N2," & """ & "-" & """ & ",REPT(" & """ & " " & """ & ",100)),100))" - which also doesn't work!!!
what I basically have is a list in one column of supplier name and number (separated by '-' ie A SUPPLIER-OR12_12345) and I need to extract the supplier number (OR12_12345) to enable me to do a lookup to another report
Any help would be greatly appreciated
Thanks in advance!
Janet