Hey folks!
I've been working on a macro to prepare a spreadsheet for upload to our database. There are a few stringent rules - the first of which is that the cells cannot contain more than 28 characters. Here's the code I have at the moment:
' 12. Trim all cells (at the moment, every worksheet) to 28 characters
Dim c As Range
Dim i As Long
For i = 1 To Worksheets.Count
For Each c In Worksheets(i).UsedRange.Cells
If Len(c) > 28 Then
c.Value = Left(c, 28)
End If
Next
Next i
This works, except for when I use spreadsheets with large numbers of rows, at which point I get an Overflow error, which highlights "If Len(c) > 28 Then".
I'm guessing that variable "c" is getting over-filled. Not sure how I can cope with this however, as I can't seem to get any other variable types to work.
The code does not need to run on every worksheet; only Sheet1.
Looking forward to your replies
I've been working on a macro to prepare a spreadsheet for upload to our database. There are a few stringent rules - the first of which is that the cells cannot contain more than 28 characters. Here's the code I have at the moment:
' 12. Trim all cells (at the moment, every worksheet) to 28 characters
Dim c As Range
Dim i As Long
For i = 1 To Worksheets.Count
For Each c In Worksheets(i).UsedRange.Cells
If Len(c) > 28 Then
c.Value = Left(c, 28)
End If
Next
Next i
This works, except for when I use spreadsheets with large numbers of rows, at which point I get an Overflow error, which highlights "If Len(c) > 28 Then".
I'm guessing that variable "c" is getting over-filled. Not sure how I can cope with this however, as I can't seem to get any other variable types to work.
The code does not need to run on every worksheet; only Sheet1.
Looking forward to your replies