+ Reply to Thread
Results 1 to 8 of 8

Using vba -how do I remove characters from right of space on all cells in specific columns

Hybrid View

gbegnell Using vba -how do I remove... 06-08-2021, 09:46 PM
alansidman Re: Using vba -how do I... 06-08-2021, 10:31 PM
gbegnell Re: Using vba -how do I... 06-08-2021, 10:33 PM
vcoolio Re: Using vba -how do I... 06-08-2021, 10:40 PM
gbegnell Re: Using vba -how do I... 06-08-2021, 11:49 PM
jindon Re: Using vba -how do I... 06-08-2021, 11:10 PM
gbegnell Re: Using vba -how do I... 06-08-2021, 11:48 PM
jindon Re: Using vba -how do I... 06-08-2021, 11:53 PM
  1. #1
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,115

    Re: Using vba -how do I remove characters from right of space on all cells in specific col

    Hello GBegnall,

    Try it as follows:-

    Sub Test()
    
    Dim c As Range
    
        For Each c In Sheet1.Range("E1", Sheet1.Range("G" & Sheet1.Rows.Count).End(xlUp))
              c.Replace What:=Right(c, 12), Replacement:=""
        Next c
        
    End Sub
    If your data starts in E3, then change E1 in the code to E3.

    I hope that this helps.

    Cheerio,
    vcoolio.
    Last edited by vcoolio; 06-08-2021 at 11:10 PM. Reason: New code

  2. #2
    Registered User
    Join Date
    06-08-2021
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    4

    Re: Using vba -how do I remove characters from right of space on all cells in specific col

     Sub Test()
    
    Dim c As Range
    
        For Each c In Sheet1.Range("E1", Sheet1.Range("G" & Sheet1.Rows.Count).End(xlUp))
              c.Replace What:=Right(c, 12), Replacement:=""
        Next c
        
    End Sub

    This also works but not all cells format as dates

    When I use the column filter only some of the cell values list within the relevant year.

    Attachment 735840

    even though the entire column is formatted as date d/mm/yyyy
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by gbegnell; 06-08-2021 at 11:57 PM.

+ 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] How to remove first 8 characters (including space) in a string
    By bala04msw in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-05-2021, 06:53 AM
  2. [SOLVED] Create a formula to remove last two characters from a cell if the 2nd character is a space
    By SellMeTv2 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-28-2019, 11:13 PM
  3. Remove all characters before space in line
    By gartie in forum Excel General
    Replies: 9
    Last Post: 08-29-2012, 05:52 PM
  4. [SOLVED] Trim Specific Values and Remove last right space
    By jantonio in forum Excel General
    Replies: 3
    Last Post: 05-02-2012, 08:40 AM
  5. Replies: 3
    Last Post: 04-05-2012, 04:58 PM
  6. Remove all characters after space
    By vsantoro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2010, 04:46 PM
  7. Remove varying amounts of space characters
    By Access Joe in forum Excel General
    Replies: 4
    Last Post: 01-13-2006, 06:30 PM

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