It is quite common that we receive the data in Excel and several times we have to remove unwanted characters from columns or modify the data as per the requirement. To avoid manual fixes of these kind of requirements, we may use Macro to automate the process which not only increase productivity but also avoid manual errors. We can easily create Macro to quickly fix it. Here are the steps to create Macro and run it.
Reference Code(to remove line breaks from columns):
Sub MyCustomMacro()
Dim MyRange As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each MyRange In ActiveSheet.UsedRange
If 0 < InStr(MyRange, Chr(10)) Then
MyRange = Replace(MyRange, Chr(10), "")
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Comments
Post a Comment