Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Delete characters in cell

Hello

I have a cell containing characters in A1
The Characters are right aligned. I want to delete the righmost 6 characters
in the cell.
I am trying something like

Sub Remove_Characters()
Anystring = Range("a1")
MyStr = Right(Anystring,6)
MyStr Delete
End Sub

It isn't working. Am I using Delete in the correct context?

Thanks
I am running Win XP Pro and Excel Office XP


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Delete characters in cell

I'm guessing you want something like this.

Sub StripRight()
Dim rngCell As Range
For Each rngCell In Selection
rngCell.Value = Right(rngCell.Value, 6)
Next rngCell
End Sub

Robin Hammond
www.enhanceddatasystems.com


"AuthorizedUserPF" wrote in message
...
Hello

I have a cell containing characters in A1
The Characters are right aligned. I want to delete the righmost 6

characters
in the cell.
I am trying something like

Sub Remove_Characters()
Anystring = Range("a1")
MyStr = Right(Anystring,6)
MyStr Delete
End Sub

It isn't working. Am I using Delete in the correct context?

Thanks
I am running Win XP Pro and Excel Office XP




  #3   Report Post  
Posted to microsoft.public.excel.programming
acw acw is offline
external usenet poster
 
Posts: 19
Default Delete characters in cell

G'day

Try
Sub Remove_Characters()
Range("a1") = Left(Range("a1").Value, Len(Range
("a1").Value) - 6)
End Sub

Tony
-----Original Message-----
Hello

I have a cell containing characters in A1
The Characters are right aligned. I want to delete the

righmost 6 characters
in the cell.
I am trying something like

Sub Remove_Characters()
Anystring = Range("a1")
MyStr = Right(Anystring,6)
MyStr Delete
End Sub

It isn't working. Am I using Delete in the correct

context?

Thanks
I am running Win XP Pro and Excel Office XP


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Delete characters in cell


"AuthorizedUserPF" wrote in message
...
Hello

I have a cell containing characters in A1
The Characters are right aligned. I want to delete the righmost 6

characters
in the cell.
I am trying something like

Sub Remove_Characters()
Anystring = Range("a1")
MyStr = Right(Anystring,6)
MyStr Delete
End Sub

It isn't working. Am I using Delete in the correct context?

Thanks
I am running Win XP Pro and Excel Office XP



No, you aren't using it correctly. Assuming you want to place the shorter
string in cell a1, then try this:

Sub Remove_Characters()
Anystring = Range("a1").value

' Compute current length of string
myLen = Len(Anystring)

' Note: extra variables introduced for illustratation.
' delete the extra variables to simplify the routine

If myLen 6 Then
' What is length of string six characters shorter?
newLen = myLen - 6

' Set new string to the new, shorter length
newString = Left(Anystring, newLen)
' Note: might want to include the TRIM function for the new string,
depending on how you feel about spaces.

' And save that value in the cell
Range("a1").Value = newString
End If

End Sub

Regards,

- Sox


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
how to delete last X number of characters in a cell [email protected] Excel Discussion (Misc queries) 3 July 25th 07 05:02 PM
Delete first two characters in a cell... ChuckF Excel Worksheet Functions 6 September 5th 06 08:46 PM
Delete first few cell characters mohd21uk via OfficeKB.com Excel Discussion (Misc queries) 4 June 7th 06 12:32 PM
delete all the cell that contains more than 25 characters [email protected] Excel Discussion (Misc queries) 2 June 7th 06 12:06 PM
can i delete the last 3 characters in each cell in a column in 1 . homer Excel Discussion (Misc queries) 7 December 15th 05 02:51 AM


All times are GMT +1. The time now is 04:06 PM.

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"