Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Joe Gieder
 
Posts: n/a
Default REPLACE or ??, Help please

First, Thank you for all the help and support.

I have a many cells similar to 01037DL530001-101 and want to remove
everything from the "-" to the end. I tried replace but can't seem to get it
to work. The one thing to keep in mind is that the numbers of characters or
numbers varies after the dash.

Thank you for your help
Joe
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
just_jon
 
Posts: n/a
Default REPLACE or ??, Help please

You could use code. The below is set to use the current selection as
its target range, but you could use a static range or the entire used
range.

Sub TruncCells()
Dim c As Range, i As Integer
Application.ScreenUpdating = False
For Each c In Selection
If Not c.HasFormula Then
i = InStr(1, c.Value, "-")
If i 0 Then c.Value = Left(c.Value, i - 1)
End If
Next c
Application.ScreenUpdating = False
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pete
 
Posts: n/a
Default REPLACE or ??, Help please

I think you would want the screen updating to be set to True at the end
of the function!

Pete

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
just_jon
 
Posts: n/a
Default REPLACE or ??, Help please

Yup, that's what I get for copy/pasting ...

Sub TruncCells()
Dim c As Range, i As Integer
Application.ScreenUpdating = False
For Each c In Selection
If Not c.HasFormula Then
i = InStr(1, c.Value, "-")
If i 0 Then c.Value = Left(c.Value, i - 1)
End If
Next c
Application.ScreenUpdating = TRUE ' *********** NOTE EDIT
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
LearningExcel
 
Posts: n/a
Default REPLACE or ??, Help please

If the number of characters before the dash are consistent, then you may use:

=left(a2,14)

14 is the length of the string before the dash.

thanks.

"Joe Gieder" wrote:

First, Thank you for all the help and support.

I have a many cells similar to 01037DL530001-101 and want to remove
everything from the "-" to the end. I tried replace but can't seem to get it
to work. The one thing to keep in mind is that the numbers of characters or
numbers varies after the dash.

Thank you for your help
Joe

Reply
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
Edit Replace Zee Excel Discussion (Misc queries) 1 January 5th 06 08:56 PM
find replace format neeraj Excel Discussion (Misc queries) 6 September 20th 05 05:50 PM
Search and replace Subu Excel Worksheet Functions 4 June 9th 05 07:01 PM
replace absolute references bj Excel Worksheet Functions 0 May 20th 05 07:18 PM
REPLACE outside of highlighted column Jane Excel Worksheet Functions 8 May 19th 05 01:54 PM


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

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

About Us

"It's about Microsoft Excel"