ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Stripping The First Four Characters from a value (https://www.excelbanter.com/excel-discussion-misc-queries/127891-stripping-first-four-characters-value.html)

Rob

Stripping The First Four Characters from a value
 
Hi,
What I am trying to figure out is how I can remove the first four characters
via a VBA Macro from a value of a cell.

Here's the example...

Edition = ActiveCell.FormulaR1C1 (this returns a value of "Rev XA" or "Rev
-" or "Rev 2")

What I want the macro to do is strip the "Rev " and just keep everything
from the fifth character on so I get (XA or - or 2)

Any Ideas??

Thanks In Advance,
Rob

Harlan Grove

Stripping The First Four Characters from a value
 
Rob wrote...
What I am trying to figure out is how I can remove the first four characters
via a VBA Macro from a value of a cell.

....

Try

somecell.Value = Mid(somecell.Value, 5)


Gary''s Student

Stripping The First Four Characters from a value
 
similar to the technique used in the worksheet:

edition = Right(edition, Len(edition) - 4)
--
Gary''s Student
gsnu200702


"Rob" wrote:

Hi,
What I am trying to figure out is how I can remove the first four characters
via a VBA Macro from a value of a cell.

Here's the example...

Edition = ActiveCell.FormulaR1C1 (this returns a value of "Rev XA" or "Rev
-" or "Rev 2")

What I want the macro to do is strip the "Rev " and just keep everything
from the fifth character on so I get (XA or - or 2)

Any Ideas??

Thanks In Advance,
Rob


Dave Peterson

Stripping The First Four Characters from a value
 
If all your data to fix is in the same column, you could record a macro when you
select that range.

Then Data|Text to columns
Fixed width
draw a line between the 4th and 5th character (and no other lines)
and skip (do not import) that first field.

With lots of data, I would bet that this would be faster than looping through
the range.

Rob wrote:

Hi,
What I am trying to figure out is how I can remove the first four characters
via a VBA Macro from a value of a cell.

Here's the example...

Edition = ActiveCell.FormulaR1C1 (this returns a value of "Rev XA" or "Rev
-" or "Rev 2")

What I want the macro to do is strip the "Rev " and just keep everything
from the fifth character on so I get (XA or - or 2)

Any Ideas??

Thanks In Advance,
Rob


--

Dave Peterson

Rob

Stripping The First Four Characters from a value
 
THANK YOU SOOO VERY MUCH!!! That was the perfect solution that I was looking
for!

Thanks Again,
Cheers!
Rob

"Gary''s Student" wrote:

similar to the technique used in the worksheet:

edition = Right(edition, Len(edition) - 4)
--
Gary''s Student
gsnu200702


"Rob" wrote:

Hi,
What I am trying to figure out is how I can remove the first four characters
via a VBA Macro from a value of a cell.

Here's the example...

Edition = ActiveCell.FormulaR1C1 (this returns a value of "Rev XA" or "Rev
-" or "Rev 2")

What I want the macro to do is strip the "Rev " and just keep everything
from the fifth character on so I get (XA or - or 2)

Any Ideas??

Thanks In Advance,
Rob



All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com