Delete 1st character if string is longer than 6 characters

  • Thread starter Thread starter DIDS
  • Start date Start date
D

DIDS

Hello,

I have a list of values in column C (275,372 cells) and would
like to know if there is a way to look at each cell and delete the 1st
character if the string is longer than 6 characters. Below is what
the before sample would look like.

009075
009130
0009767
010471
010489
011640
013373
013824
017424
019038
020634
020642
020663
0020711
020723

So the above list will look like this after:

009075
009130
009767
010471
010489
011640
013373
013824
017424
019038
020634
020642
020663
020711
020723



Thanks you for any help you can provide,

DIDS
 
Hello DIDS,

Am Wed, 11 Apr 2012 10:33:23 -0700 (PDT) schrieb DIDS:
I have a list of values in column C (275,372 cells) and would
like to know if there is a way to look at each cell and delete the 1st
character if the string is longer than 6 characters.

try:
Sub myString()
Dim LRow As Long
Dim c As Range

LRow = Cells(Rows.Count, 3).End(xlUp).Row
For Each c In Range("C1:C" & LRow)
If Len(c) > 6 Then
c = Right(c, Len(c) - 1)
End If
Next
End Sub


Regards
Claus Busch
 
Hi Claus Busch,


Your code worked perfectly. Thank you very much for your
assistance.


Thanks,

DIDS
 
Back
Top