+ Reply to Thread
Results 1 to 3 of 3

VBA: Delete Last 15 Characters in a String in Columns If Cell is not empty

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    1

    VBA: Delete Last 15 Characters in a String in Columns If Cell is not empty

    Hello,

    I need to write a macro, whereby it selects a cell in column (example starts in Column F and goes down the various rows in column F).
    If the cell has text in it, delete the last 15 characters. If the cell is blank move onto the next cell.

    Here is the code so far:


    Dim f as Range
    For Each f In Range ("F2", Range("F" & Rows.Count).End(xlUp))
    If ' cell is empty go to next cell'
    ElseIf 'cell is not empty' Then
    f.Value=Left(f.Value, Len(f.value) -15)
    End If
    Next i
    End Sub

    The part of code I am missing is If the cell is empty, go to the next cell in the range and if cell is not empty Then delete the last 15 characters.

    Thanks!

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello bfrankie,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    10-03-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: VBA: Delete Last 15 Characters in a String in Columns If Cell is not empty

    Code so that it is easier to read


    Please Login or Register  to view this content.

+ 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. delete last 5 characters from string
    By leooconnor in forum Excel General
    Replies: 6
    Last Post: 01-02-2015, 08:50 PM
  2. [SOLVED] Delete specific characters from right side of string
    By Drudnits1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-29-2014, 02:12 PM
  3. Replies: 7
    Last Post: 07-25-2014, 08:21 AM
  4. Delete Empty Rows and empty columns from the word table
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 10:51 AM
  5. Replies: 4
    Last Post: 12-08-2010, 01:28 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