ThrottleWorks
Excel Ninja
Hi,
I am using below code to trim a range. However this code is taking time.
Can anyone please suggest me a better code to trim data.
Thanks.
I am using below code to trim a range. However this code is taking time.
Can anyone please suggest me a better code to trim data.
Thanks.
Code:
Sub Trim_Raw_Data()
Dim RawSht As Worksheet
Dim TempLr As Long
Dim TempRng As Range
Dim TRng As Range
Dim LastCol As Long
LastCol = 17 'Q
Set RawSht = ActiveSheet
TempLr = RawSht.Cells(RawSht.Rows.Count, 1).End(xlUp).Row
Set TempRng = RawSht.Range(RawSht.Cells(1, 1), RawSht.Cells(TempLr, LastCol))
For Each TRng In TempRng
TRng = Trim(TRng)
Next TRng
End Sub