I changed the formula into value with the first codes below. This code, however, has some limitation. The value of the selected cells which starts with 0, for example, 0022111, will be turned into 22111 with this code. So I came up with the second one. What would you do if it were you?
With Range("D4", Range("D65536").End(xlUp)).Offset(0, 1) .Formula = "=LEFT(RC[-1],FIND(""/"",RC[-1])-1)" .Value = .Value End WithWith Range("D4", Range("D65536").End(xlUp)).Offset(0, 1) .Formula = "=LEFT(RC[-1],FIND(""/"",RC[-1])-1)" .Copy End With Selection.PasteSpecial Paste:=xlPasteValues
Last edited by alexxgalaxy; 09-17-2011 at 09:48 AM.
Maybe
With Range("D4", Range("D65536").End(xlUp)).Offset(0, 1) .Formula = "=LEFT(RC[-1],FIND(""/"",RC[-1])-1)" .Value = Format(.Value, "0000000") End With
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thanks Roy but there is still limitation. The codes above can handle the example "0022111" I quoted but the real life case is there is no fix length for the value of every cells in selection. It could take six spaces as it did in my example but it could also take ten or even more.
Last edited by alexxgalaxy; 09-17-2011 at 08:04 PM.
Please don't quote whole posts. You didn't say that the the values were varying lengths
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks