Removing Excess Spaces in a String

madhuchelliah

Board Regular
Joined
Nov 22, 2017
Messages
226
Office Version
  1. 2019
Platform
  1. Windows
Hello all, i want to remove more than one space between the contents in the string. The string is always in the last used cell of H column. The string contains both single and double spaces. The macro should delete the double space alone and leave the single space as it is. Please heads up. Thank you.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try
Code:
Sub RemBlank()
With Range("H" & Rows.count).End(xlUp)
   .Value = WorksheetFunction.trim(Range("H" & Rows.count).End(xlUp).Value)
End With
End Sub
 
Upvote 0
Hello Fluff, its working great. Could you please look into the similar one. In case if there is now spaces between characters how to add spaces between the characters in the string. The macro should add space between each character.If already space is exist it should ignore and add only where space is required. The string is in last used row of H column. Thank you.
 
Upvote 0
As this is a completely different question, can you please start a new thread?
 
Upvote 0

Forum statistics

Threads
1,215,520
Messages
6,125,301
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top