Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Removing trailing spaces in a spreadsheet | Excel Discussion (Misc queries) | |||
Removing leading/trailing spaces | Excel Discussion (Misc queries) | |||
REMOVING TRAILING SPACES | Excel Discussion (Misc queries) | |||
How keep Leading/Trailing spaces when save in Excel? | Excel Discussion (Misc queries) | |||
Delete leading or trailing blank spaces in cell - an example | Excel Programming |