View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
maryj maryj is offline
external usenet poster
 
Posts: 76
Default macro to update last character

Thanks Mike! Work like a dream!!!
--
maryj


"Mike H" wrote:

Hi,

Try this. Change Sht variable to the name of your sheet

Sub last_Char()
Dim LastRow As Long
Dim MyRange As Range, c As Range
Set sht = Sheets("Sheet2") ' change to suit
LastRow = sht.Cells(Cells.Rows.Count, "G").End(xlUp).Row
Set MyRange = sht.Range("G1:G" & LastRow)
For Each c In MyRange
c.Value = Left(c.Value, Len(c.Value) - 1) & _
Right(c.Value, 1) + 1
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"maryj" wrote:

We are using Excel 2007. We have a large list of id numbers that will need
the last character changed from a 1 to 2. The length of the list will always
vary but will always be in Column G.

For example:
11323674US01
11321507US01
11378181US01
need to be updated to:
11323674US02
11321507US02
11378181US02

Thanks for your help!

--
maryj