+ Reply to Thread
Results 1 to 2 of 2

identifying the first character in a string

Hybrid View

  1. #1
    dstiefe
    Guest

    identifying the first character in a string

    I have several colums of data with names. The names are inputed in the
    following way:
    'daniel
    'michael
    'ted

    how do i loop through the column and erase only the " ' " that is beginning
    of each name?

    Thank you

  2. #2
    GS
    Guest

    RE: identifying the first character in a string

    Hi dstiefe,

    You could try this. Note that it requires at least one cell in the target
    column is selected.

    Sub RemoveFirstChar()
    ' Removes the first character in a string value
    ' Requires that any cell(s) in the target column be selected

    Dim c As Range
    Dim lLastRow As Long, r As Long, iCol As Integer

    iCol = Selection.Column
    lLastRow = Cells(Rows.Count, iCol).End(xlUp).Row

    For r = 1 To lLastRow
    If Not IsEmpty(Cells(r, iCol)) Then
    If Left$(Cells(r, iCol).Value, 1) = Chr$(39) Then _
    Cells(r, iCol).Value = Mid$(Cells(r, iCol).Value, 2)
    End If
    Next
    End Sub


    Regards,
    GS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1