【发布时间】:2022-12-01 22:19:48
【问题描述】:
I want to write a function that will find all spaces and remove them from my data, however, I need it to skip the first line in the excel sheet as that is the header line that needs to keep its spaces. For example, I have a column with the header Power with the column index of 5, I want the function to search from column 5 row 2 to the last row with data in column 5 for spaces. If there are spaces that exist in the data, I want them to be removed and replaces with no space.
This is what I have tried so far, however, I cannot get it to remove the spaces when I test it.
Sub removespace()
Range(2,5, cells(rows.Count,5).End(xlUp)).Select
Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End Sub
【问题讨论】: