PC Review


Reply
Thread Tools Rate Thread

deleting text

 
 
dstiefe
Guest
Posts: n/a
 
      12th Apr 2009
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
 
Reply With Quote
 
 
 
 
AltaEgo
Guest
Posts: n/a
 
      12th Apr 2009
Depends what you are trying to achieve. Enter a value in cell A2. In another
cell


a) If you only ever want the last 4 characters:

=Left(A2,4)

b) if the value varies in length and you always want to drop the first five
characters:

=RIGHT(A2,LEN(A2)-5)

c) if you want to split at the decimal:

=RIGHT(A2,(LEN(A2)-FIND(".",A2)+1))


The same principal applies in VBA. Just assign a value to a variable,
replace references to the required cell (shown as A2 above) with the
variable.

When you finish, if you need to get rid of the original values:

1) Highlight the range with your formula.
2) Copy.
3) Move where you want your values.
4) Paste special/Values.
5) Delete superfluous data





--
Steve

"dstiefe" <(E-Mail Removed)> wrote in message
news:7D500A23-CDE8-4F83-B777-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      12th Apr 2009
On Sat, 11 Apr 2009 19:36:01 -0700, dstiefe <(E-Mail Removed)>
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
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      13th Apr 2009
> 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Sat, 11 Apr 2009 19:36:01 -0700, dstiefe
> <(E-Mail Removed)>
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change my space bar from deleting text to moving text malisam71 Microsoft Word Document Management 1 1st Sep 2009 04:32 PM
text box fields keep erasing when deleting body text somo Microsoft Word Document Management 1 17th Mar 2009 02:55 PM
Deleting Text Boxes without Deleting Text. green Microsoft Word Document Management 2 12th Feb 2009 05:51 AM
Deleting the text without deleting the formula gems04 Microsoft Excel Worksheet Functions 3 30th Jan 2009 11:21 PM
Deleting text from one control based on the value/text of the othe SPK Microsoft Access Forms 1 11th Jun 2008 08:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:03 PM.