Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
On reflection I should have included a chack to ensure the rightmost character was numeric 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 If IsNumeric(Right(c.Value, 1)) Then c.Value = Left(c.Value, Len(c.Value) - 1) & _ Right(c.Value, 1) + 1 End If Next End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to update last character | Excel Programming | |||
Help - macro messes up the character formating | Excel Programming | |||
Macro to delete 'tick' Character | Excel Programming | |||
Hidden Character Find Macro Help | Excel Programming | |||
Setting character colour in a macro | Excel Discussion (Misc queries) |