Hello I have large datasets that I run automated processes on that I need to trim and clean and have been using:
for this. It executes in a few seconds if I use an array and loop through the data it takes minutes
But my recent datasets some cells exceed the character limit and these cells are given the value "#VALUE!" by my function
I want to test for the character limit and if it is exceeded then skip those cells or post back there value
I have tried (and similar things)
but not getting how to postback the value of the cell.
Thanks for any help on this
VBA Code:
Function CleanSheets(arrShtNames As Variant, startRow As Long)
Dim ws As Worksheet
Dim rng As Range
Dim LR As Long, Lc As Long
For Each ws In Worksheets(arrShtNames)
With ws
Lc = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
LR = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set rng = .Range("A" & startRow).Resize(LR, Lc)
rng.Replace what:=vbNullChar, Replacement:=vbNullString
rng.Replace what:="#NULL!", Replacement:=vbNullString
rng.Replace what:="#VALUE!", Replacement:=""
rng = Evaluate("IF(" & rng.Address & "="""","""",CLEAN(TRIM(" & rng.Address & ")))")
End With
Next ws
End Function
for this. It executes in a few seconds if I use an array and loop through the data it takes minutes
But my recent datasets some cells exceed the character limit and these cells are given the value "#VALUE!" by my function
I want to test for the character limit and if it is exceeded then skip those cells or post back there value
I have tried (and similar things)
Code:
rng = Evaluate("IF(Len(" & rng.Address & ")<256,CLEAN(TRIM(" & rng.Address & ")), rng.adress.value)")
but not getting how to postback the value of the cell.
Thanks for any help on this