How do I remove a character from a column of data in Excel

后端 未结 1 1748
太阳男子
太阳男子 2021-01-25 09:52

I am formatting some data I received. I have several hundred names of students in Column A, and for some strange reason there is a random * placed randomly through

相关标签:
1条回答
  • 2021-01-25 10:31

    You don't need to loop through the cell. You can use Excel's inbuilt .Replace function to replace all * by using "~*"

    Here is an example

    Option Explicit
    
    Sub Sample()
        Dim ws As Worksheet
        Dim Rng As Range
    
        '~~> Change this to the relevant worksheet
        Set ws = ThisWorkbook.Sheets("Sheet1")
    
        '~~> Change this to the relevant range
        Set Rng = ws.Range("A2:A300")
    
        Rng.Replace What:="~*", Replacement:="", LookAt:=xlPart, SearchOrder _
        :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    End Sub
    
    0 讨论(0)
提交回复
热议问题