Hi,
I am new to vba and am stuck on how I get the below split into three columns?
A1=102341,80USD0,00
A2= 102341.80 (will also change the comma to a decimal afterwards)
A3=USD
A4=0,00 (will be deleted afterwards)
Thanks
Hi,
I am new to vba and am stuck on how I get the below split into three columns?
A1=102341,80USD0,00
A2= 102341.80 (will also change the comma to a decimal afterwards)
A3=USD
A4=0,00 (will be deleted afterwards)
Thanks
Do you need VBA ?
above assumes![]()
A2: =LOOKUP(9.99E+307,LEFT(SUBSTITUTE(A1,",","."),ROW($1:$15))+0) A3: =LEFT(REPLACE(A1,1,LEN(TEXT(A2,"0.00")),""),3)
all can be adapted as necessary.a) no leading zeroes in first number
b) first number always has 2 decimals (denoted by comma delimiter)
c) first number is followed by 3 letter currency code
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Yes, I do need VBA. I was able to get it to work in a normal excel sheet, but not in visual basic. There are actually multiple lines of data which require the same formatting and is currently in column K of my worksheet.
Here is a sample of additional lines:
102341,80USD0,00
31686,37USD0,00
42541,81USD0,00
89334,48USD0,00
92535,84USD0,00
The script I was attempting to use was:
What I need is for the currency "USD" to go into column I and the number (ex.102,341.80) to remain in column K.![]()
Columns("K:K").Select Range("K1").Select For i = 1 To Selection.CurrentRegion.Rows.Count ActiveCell.FormulaR1C1 = "=LOOKUP(9.99E+307,LEFT(SUBSTITUTE(K1,",","."),ROW($1:$15))+0)" ActiveCell.Offset(1, 0).Select Next
Last edited by DonkeyOte; 01-20-2011 at 04:59 PM.
Per Forum Rules - please always use CODE tags when posting VBA.
Numerous approaches - no doubt plenty more efficient than the below but I'm rushing off I'm afraid so not much thought has gone into the below I'm afraid
change Sheet reference as per your requirements![]()
Sub Example() Dim vStr As Variant, vVal As Variant, lngVal As Long, dblVal As Double With Sheets("Sheet1") With .Range(.Cells(1, "K"), .Cells(.Rows.Count, "K").End(xlUp)) vStr = Application.Transpose(.Value) ReDim vVal(1 To UBound(vStr)) For lngVal = LBound(vStr, 1) To UBound(vStr, 1) Step 1 vVal(lngVal) = Format(Val(Replace(vStr(lngVal), ",", ".", 1, 1)), "0.00") vStr(lngVal) = Left(Replace(Replace(vStr(lngVal), ",", ".", 1, 1), vVal(lngVal), "", 1, 1), 3) Next lngVal .Value = Application.Transpose(vVal) .Offset(, -2).Value = Application.Transpose(vStr) End With End With End Sub
Is the trailing value always 0,00 ? (and/or always has 2 decimals)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks