+ Reply to Thread
Results 1 to 3 of 3

vbYesNo + Clean and Trim Selection

  1. #1
    Forum Contributor
    Join Date
    11-29-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    104

    vbYesNo + Clean and Trim Selection

    I have some code that is functioning as desired. It takes the users selection and cleans and trims each cell.
    My question is, is the code listed below the best way to go about this?

    Please Login or Register  to view this content.
    Any edits or suggestions would be welcome

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: vbYesNo + Clean and Trim Selection

    using Evaluate is a quick method, certainly -- looking at your code

    a) you might want to move your final End If {re: Filter test} to above 'Weed out... else if no Auto Filter in place at run-time then no routine.
    b) you might want to add a MsgBox advising of abort if user opts to preserve the filter
    c) you might want to leverage the intersect of the UsedRange relative to the Selection (e.g. should user select all cells on tab, for ex.)
    d) you might want to further restrict your SpecialCells reference with optional parameter of xlTextValues

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: vbYesNo + Clean and Trim Selection

    Hi, The only thing I wonder is why evaluate if you're trimming the cells?
    The user has already selected an area, so just treat each cell in that area.

    Please Login or Register  to view this content.
    Something like this maybe?
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] macro to use for excel to clean and trim coumns a2:a100
    By David713 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-07-2017, 12:02 PM
  2. Using TRIM, SUBSTITUTE & CLEAN
    By scarames in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-18-2014, 03:13 PM
  3. When TRIM() and CLEAN() fail.
    By fhalejr in forum Excel General
    Replies: 7
    Last Post: 01-02-2014, 02:12 AM
  4. [SOLVED] Clean and Trim Not Working
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-05-2013, 07:14 PM
  5. [SOLVED] Clean Trim Proper Function Using a Macro
    By kamalthakur in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-14-2012, 09:06 PM
  6. Can't 'trim' or 'clean' spaces
    By [email protected] in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-05-2010, 07:06 PM
  7. Clean and Trim
    By tl7410 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2009, 03:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1