VBA Remove Spaces Between Characters and Numbers within Range in Excel

VBA Remove Spaces Between Numbers and Characters fi

VBA Delete Spaces Between numbers and characters within range in Excel. We can use Find and Replace VBA functions to remove spaces completely between characters and numbers.

Macro to Remove Spaces Between characters and Numbers within Range in Excel VBA

Let us see the example macro to Remove Spaces within Range in Excel VBA.

'Macro to Remove Spaces Between Numbers and Characters within Range in Excel VBA
Sub VBA_Remove_Spaces_Between_Numbers_Characters()

    'Variable Declaration
    Dim rRange As Range
    
    Set rRange = ActiveSheet.Range("A1:G200")
    rRange.Replace What:=Space(1), Replacement:="", _
          SearchOrder:=xlByColumns, MatchCase:=True
          
    Set rRange = rRange.Find(What:=Space(1))
    
    If Not rRange Is Nothing Then
        'Procedure repeats until all spaces are removed
       Call VBA_Remove_Spaces_Between_Words
    End If
    
End Sub

output: Here is the output screenshot of above macro code.

VBA Remove Spaces Between Numbers and Characters

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog

Leave a Comment