Text to Fraction

G

Guest

I copied some fraction from internet which may be in text format, but there
is no single quote in front of them. How can I change them to fractions or
numbers by using VBA code. Could somebody please help.

Thanks
 
G

Guest

Hi alan,

Really need to see a sample of the fractions. If it looks like this 1/2 then
it is easy. See example below. Otherwise not so easy.

celValue = ActiveCell

dividePos = InStr(1, celValue, "/") 'Position of division sign

dividend = Val(Left(celValue, dividePos - 1))

divisor = Val(Mid(celValue, dividePos + 1))

result = dividend / divisor

Regards,

Ossiemac
 
N

Niek Otten

Maybe you don't need VBA:

Format an empty cell as number. Edit>Copy. Select your fractions. Edit>Paste special, check Multiply.

Depending on what your fractions look like, they may also be converted to dates, so be careful.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

|I copied some fraction from internet which may be in text format, but there
| is no single quote in front of them. How can I change them to fractions or
| numbers by using VBA code. Could somebody please help.
|
| Thanks
 
N

Niek Otten

<check Multiply>

Make that:

check Add

!!

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

| Maybe you don't need VBA:
|
| Format an empty cell as number. Edit>Copy. Select your fractions. Edit>Paste special, check Multiply.
|
| Depending on what your fractions look like, they may also be converted to dates, so be careful.
|
| --
| Kind regards,
|
| Niek Otten
| Microsoft MVP - Excel
|
||I copied some fraction from internet which may be in text format, but there
|| is no single quote in front of them. How can I change them to fractions or
|| numbers by using VBA code. Could somebody please help.
||
|| Thanks
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top