Hi There
Is there anyone that can give me assistance. I am preparing a large file for importing and I need to make sure that each cell in my range contains precisly 68 characters including spaces. I have this piece of code but can not work out how to get it to add the spaces. I have tried using the replacement:="(Spaces)" to create the required spaces but is not working?
Sub Add_Spaces()
Application.ScreenUpdating = False
Dim SelectedCell As Range
Dim Letters As String
Dim Spaces As String
For Each SelectedCell In Selection
Letters = ActiveCell.Characters.Count
Spaces = 68 - Letters
Selection.Replace What:="", Replacement:="(Spaces)", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
MsgBox Spaces
Next
Application.ScreenUpdating = True
End Sub
As per usual any help would be gratfully received.
Kind regards
Peter
Is there anyone that can give me assistance. I am preparing a large file for importing and I need to make sure that each cell in my range contains precisly 68 characters including spaces. I have this piece of code but can not work out how to get it to add the spaces. I have tried using the replacement:="(Spaces)" to create the required spaces but is not working?
Sub Add_Spaces()
Application.ScreenUpdating = False
Dim SelectedCell As Range
Dim Letters As String
Dim Spaces As String
For Each SelectedCell In Selection
Letters = ActiveCell.Characters.Count
Spaces = 68 - Letters
Selection.Replace What:="", Replacement:="(Spaces)", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
MsgBox Spaces
Next
Application.ScreenUpdating = True
End Sub
As per usual any help would be gratfully received.
Kind regards
Peter