![]() |
removing leading and trailing spaces
I have excel worksheet with some data in the cells. But in each cell the data
has leading and traliling spaces. I don't have any hidden characters. I save this excel file as CSV file but CSV file is preserving these spaces. Does any one can help me about the VBA macro how to remove the leading and trailing spaces from all cells when I create the csv file from the excel file. The excel should not be modified in anyway. |
removing leading and trailing spaces
Note there's also a worksheet function TRIM() that has the same
functionality as the VBA one. Public Sub leadingSpaces() Dim rng As Excel.Range Dim wsh As Excel.Range Application.ScreenUpdating = False Set wsh = Application.ActiveSheet.UsedRange For Each rng In wsh rng.Value = Trim(rng.Value) Next rng Application.ScreenUpdating = True End Sub On Oct 31, 5:18 pm, Ram wrote: I have excel worksheet with some data in the cells. But in each cell the data has leading and traliling spaces. I don't have any hidden characters. I save this excel file as CSV file but CSV file is preserving these spaces. Does any one can help me about the VBA macro how to remove the leading and trailing spaces from all cells when I create the csv file from the excel file. The excel should not be modified in anyway. |
All times are GMT +1. The time now is 02:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com