Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing a String in a Cell 1

Status
Not open for further replies.

Killraven

Technical User
Nov 4, 2002
10
US
Ok, I have searched the forums, searched my books, but I'm missing something on this string edit/search problem.

What I want to do.

If one cell meets a certain criteria, then I want to edit a text string in another cell, depending on a few things.

For example.

If my client code starts with 'cf', 'pa', 'jp002', 'jp005', and 'jp006' then do nothing

otherwise, change the last letter of the client code from a 'g' to an 'a'

example

cc002g to cc002a


Hope that is explains it ok. I thought about counting the first incidents of a specific letter using InStr, but there may be an occurrence of cg002g. So i was stumped.

I want it to check through about 5000 different entries that use these client codes, and automating it if possible sounds good.

Thanks!

DK
 
thisVal = cells(1,1)
doIt = true
IF left(thisVal,2) = "cf" THEN doIt = false
IF left(thisVal,2) = "pa" THEN doIt = false
IF left(thisVal,5) = "jp002" THEN doIt = false
IF left(thisVal,5) = "jp005" THEN doIt = false
IF left(thisVal,5) = "jp006" THEN doIt = false

IF doIt THEN
cells(2,2) = left(cells(2,2),5) + "a"
END IF

-- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top