LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default deleting text

c.Value = _
WorksheetFunction.Replace(c.Text, 1, 5, "")


You can also use VB's built in Mid function to do that as well...

c.Value = Mid(c.Text, 6)

where the 6 is one more than the number of beginning characters that are to
be removed.

--
Rick (MVP - Excel)


"Ron Rosenfeld" wrote in message
...
On Sat, 11 Apr 2009 19:36:01 -0700, dstiefe

wrote:

I have values in a cell

A3452.79%

I need to delete the first 5 characters from the cell.

how do i do that?

Thank you


The Replace *worksheet function* does that. Since you posted in a
programming
group, I will suggest a VBA macro.

To enter this Macro (Sub), <alt-F11 opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this Macro (Sub), first select a range to process.

Then <alt-F8 opens the macro dialog box. Select the macro by name, and
<RUN.

================================
Sub Rem5()
Dim c As Range, Rng As Range
Set Rng = Selection 'or whatever

For Each c In Rng
If Len(c.Text) 5 Then
c.Value = _
WorksheetFunction.Replace(c.Text, 1, 5, "")
End If
Next c
End Sub
================================
--ron


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting the text without deleting the formula gems04 Excel Worksheet Functions 3 January 30th 09 11:21 PM
Deleting text in a cell Gemi Excel Discussion (Misc queries) 4 January 27th 09 01:10 AM
Deleting Text Felix New Users to Excel 1 January 20th 09 10:14 AM
editing/deleting text Hennie Neuhoff Excel Programming 1 August 13th 08 04:32 AM
Deleting specific text using VBA ? Confused Excel Discussion (Misc queries) 4 March 20th 08 12:02 AM


All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"