Thursday, January 12, 2012

Excel VBA program to Clean Trim Values within you selection

!....Excel VBA program to clean trim values according to your selection...!

Sub Remove_Space()

Dim rw As Integer
Dim cl As Integer
Dim c, r As Integer

c = ActiveCell.Column
If ActiveCell = "" Then
MsgBox "Blank or No Cell is Selected"
Exit Sub
End If
For i = 1 To Selection.Columns.Count
r = ActiveCell.Row
For j = 1 To Selection.Rows.Count
Cells(r, c) = Trim(Cells(r, c))
r = r + 1
Next j
c = c + 1
Next i

End Sub

Sample file for the above VBA Program:----------------------------

No comments:

Post a Comment

Excel VBA to send email from excel with HTML table in a email body

'' Excel vba script to send email from outlook & email body in HTML table format. ''Write down email body in HTML tags...