Substring to replace string

A

Andrew Slentz

Hi,

I am trying to figure out an easy way to create an excel macro that will
take a substring and replace the string with that substring. Ex:
47130-5240 (original) take the first 5 characters and replace the
original value with only those first 5 characters. So the result would
be 47130 in that cell.

Any ideas???

Thanks,

Andrew

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Andrew Slentz

Hmm... Thanks a bunch. This makes sense but how do I apply that to a
specific column of an entire spreadsheet???

I am so lost...

Thanks,

Andrew

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
F

Frank Kabel

Hi
try something like
sub foo()
dim rng as range
dim cell as range
application.screenupdating=false
set rng = activesheet.range("A1:A100")
for each cell in rng
if len(cell.value)>=5 then
cell.value =left(cell.value,5)
end if
next
application.screenupdating=true
end sub
 

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