excel vba remove leading or trailing spaces in an entire column of data

'VBA function to clean data from range and return an array. This
'function does NOT use loops:

Function CleanMAX(r As Range)
    CleanMAX = Replace("trim(clean(substitute(|,char(160),"" "")))", "|", r.Address)
    If r.Cells.Count > 1 Then CleanMAX = "index(" & CleanMAX & ",)"
    CleanMAX = Evaluate(CleanMAX)
End Function

'--------------------------------------------------------------------

'Clean the value and returns a SCALAR, not an array:
v = CleanMAX([a1])

'Clean every value and create a 2D array with 10 rows and 26 columns:
v = CleanMAX([a1:z10])

'--------------------------------------------------------------------

'Note:  this function also removes non-breaking space (ASCII 160).


Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
delete leading and trailing spaces in a range of cells vba code that works fast excel vba trim leading and trailing spaces vba remove leading and trailing spaces vba code to remove leading and trailing spaces how to remove trailing spaces in excel excel remove extra cha remove space excel before text how to remove whitespace in excel how to remove all spaces before and a how to eliminate black spaces in column excel excel trim right blank spaces excel remove blank space from start of cell clean trailing whitespace excel how do i stop excel removing leading spaces in data excel removing leading spaces how to remove leading and trailing spaces in excel how to remove front and back space in excel how to trim spaces in Excel excel remove spaces at end how to remove spaces in the end of a cell in excel haw to remove spaces remove all trailing spaces in a cell excel remove all trailing spaces in excel trim right space in column excel trim right space in excel excel trim starting whitespace excel trim whitspace excel trim column in place remove blank spaces excel formula excel remove space from end of cell excel remove the first space remove leading space remove all spaces in string of 2 columns and comapre excel remove trailing and leading spaces excel function to remove trailing spaces how to remove spaces in excel excel trim spaces button delete first space in cell excel excell remove whitespace delete space in front of text excel remove blank space column excel remove leading blank in excel remove trailing space excel excel delete leading spaces excel remove leading spaces excel strip left space of column excel clear out whitespace at before text remove space begining remove starting space from excel sheet string strip trailing blanks in exce; excel remove whitespace remove trailing spaces excel strip leading whitespace remove space from column in excel remove the leading space in excel excel remove blank spaces trim a full column in excel conditional for removing spaces in cells Cannot GET /spaces remove trailing spaces in excel delete white space in excel excel remove leading spaces before text excel strip spaces from start of text excel find non-breaking space remove trailing space remove spaces from left in excel how to trim trailing space excel remove all leading and trailering spaces excel remove first space how to remove left blank spaces in excel trail whitespace in all cells excel trail whitespace excel excel get rid of trailing spaces remove space from start of cell how to delete the space before and after each row in excel remove certain leadeing spaces # remove spaces from beginning of text in excel excel delete first space how to remove space from column in excel excel add in to remove trailing space how to delete initial space on cell value excel remove leading and trailing spaces how to delete a space before a words in excel excel space before text excel trim leading spaces excel remove leading whitespace remove last space in excel =Remove After Last Space + sum how to remove spaces from excel cells trim leading spaces excel trim leading spaces in excel excel remove left space trim spaces in excel remove leading trailing spaces excel remove leading and trailing spaces in excel remove whitespace in excel how to delete spaces cells in excel excel remove space before text excel empty space in cell formula how to remove leading spaces in excel excel how to remove leading blank spaces excel how to remove leading 3 spaces excel remove spaces trim spaces at the end excel cut out all spaces in excel cell remove spaces at the end of a cell in excel remove space in front of text in excel how to remove blank spaces at the end of a cell in excel eliminate white space excel trim trailing spaces in excel excel trim doesn't remove leading spaces excel trailing space remove trailing space in excel only bigining space and numbers remove leading whitespace excel how to remover end spaces in excel cells trim space before text removing extra lines and spaces in column excel excel strip whitespace excel remove white space from cell remove line in excel starting space excel apply trim to all cells excel remove spaces before text excel remove space at beginning and end excel vba remove leading or trailing spaces in an entire column excel vba remove leading or trailing spaces in an entire column of data
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source