PDA

View Full Version : Solved: convert formula to VBA



danovkos
08-23-2010, 01:21 AM
Hi,
pls. how can i convert this formula to vba code?



=VALUE(LEFT(E10;FIND("/";E10)-1)&MID(E10;FIND("/";E10)+1;20))


thx for help

danovkos
08-23-2010, 01:45 AM
i tried this, but it doesnt works :(


b = (Left(bunka, InStr(1, "/", bunka) - 1) & Mid(bunka, InStr("/", bunka) + 1, 20))


bunka - is variable to my active cell

danovkos
08-23-2010, 01:50 AM
i got it
maybe somebody use this info


b = (Left(bunka, InStr(1, bunka, "/") - 1) & Mid(bunka, InStr(1, bunka, "/") + 1, 20))

Ken Puls
08-23-2010, 10:53 PM
I know that you worked out your answer, but out of curiosity, did you think about asking the macro recorder?

ActiveCell.FormulaR1C1 = _
"=VALUE(LEFT(R[8]C[2],FIND(""/"",R[8]C[2])-1)&MID(R[8]C[2],FIND(""/"",R[8]C[2])+1,20))"

Granted it's not as clean, but it will give you exactly what you're after. This is written in R1C1 notation, but you could just as easily convert it to A1 notation.

Hope it helps for future,

danovkos
08-30-2010, 01:46 AM
I know that you worked out your answer, but out of curiosity, did you think about asking the macro recorder?

ActiveCell.FormulaR1C1 = _
"=VALUE(LEFT(R[8]C[2],FIND(""/"",R[8]C[2])-1)&MID(R[8]C[2],FIND(""/"",R[8]C[2])+1,20))"

Granted it's not as clean, but it will give you exactly what you're after. This is written in R1C1 notation, but you could just as easily convert it to A1 notation.

Hope it helps for future,

you right, i will really help for the future. thx a lot :)