Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Cut off end of a string

When I import a string to paste I want to check the end of the string and if
the last 2 letters match one from a list then I want to delete them before I
pastea the string.
oldjay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Cut off end of a string

On Tue, 3 Mar 2009 12:02:05 -0800, Oldjay
wrote:

When I import a string to paste I want to check the end of the string and if
the last 2 letters match one from a list then I want to delete them before I
pastea the string.
oldjay


I'm not sure how you are "importing" without "pasting". Can you explain?

If you have a string in a cell, you can check to see if the last two characters
are in a "SuffixList" with this **array** formula:

=LEFT(A1,LEN(A1)-2*OR(RIGHT(A1,2)=SuffixList))

where SuffixList is the range where you have your list.

To **array-enter** a formula, after entering
the formula into the cell or formula bar, hold down
<ctrl<shift while hitting <enter. If you did this
correctly, Excel will place braces {...} around the formula.

You can then edit/copy Edit/Paste Special -- Values and then delete the
original import.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Cut off end of a string

I should have said "I am copying a string"

"Ron Rosenfeld" wrote:

On Tue, 3 Mar 2009 12:02:05 -0800, Oldjay
wrote:

When I import a string to paste I want to check the end of the string and if
the last 2 letters match one from a list then I want to delete them before I
pastea the string.
oldjay


I'm not sure how you are "importing" without "pasting". Can you explain?

If you have a string in a cell, you can check to see if the last two characters
are in a "SuffixList" with this **array** formula:

=LEFT(A1,LEN(A1)-2*OR(RIGHT(A1,2)=SuffixList))

where SuffixList is the range where you have your list.

To **array-enter** a formula, after entering
the formula into the cell or formula bar, hold down
<ctrl<shift while hitting <enter. If you did this
correctly, Excel will place braces {...} around the formula.

You can then edit/copy Edit/Paste Special -- Values and then delete the
original import.
--ron

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Cut off end of a string

This is my code

Private Sub CommandButton22_Click() 'Recalls a quote

Dim quotenumber As String
Dim QUOTE As String

Dim user As String
user = Application.UserName
MainMenu.Hide

Application.ScreenUpdating = False 'Keeps screen from updating thereby
speeding routine
Application.DisplayAlerts = False

quotenumber = InputBox("Please enter QUOTE number to recall from your
hard drive. If recalling a quote from the server" & _
"type in \\server3\jobs\estimate1\quickquotes3\ and the quote number.")
QUOTE = "C:\Quick Quotes3\" & quotenumber & ".XLS"
On Error GoTo ehandler

Workbooks.Open Filename:=QUOTE
ActiveWorkbook.SaveAs Filename:="TempData.xls"

Windows("TempData.XLS").Activate 'Recalls input saved data
Range("A2:A36").Select
Selection.Copy

This is were I want to check the last 2 letters

Windows(MasterSheet).Activate
Range("AB2").Select
Selection.PasteSpecial Paste:=xlValues

etc

"Ron Rosenfeld" wrote:

On Tue, 3 Mar 2009 12:02:05 -0800, Oldjay
wrote:

When I import a string to paste I want to check the end of the string and if
the last 2 letters match one from a list then I want to delete them before I
pastea the string.
oldjay


I'm not sure how you are "importing" without "pasting". Can you explain?

If you have a string in a cell, you can check to see if the last two characters
are in a "SuffixList" with this **array** formula:

=LEFT(A1,LEN(A1)-2*OR(RIGHT(A1,2)=SuffixList))

where SuffixList is the range where you have your list.

To **array-enter** a formula, after entering
the formula into the cell or formula bar, hold down
<ctrl<shift while hitting <enter. If you did this
correctly, Excel will place braces {...} around the formula.

You can then edit/copy Edit/Paste Special -- Values and then delete the
original import.
--ron

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Cut off end of a string

On Tue, 3 Mar 2009 15:39:36 -0800, Oldjay
wrote:

This is my code

Private Sub CommandButton22_Click() 'Recalls a quote

Dim quotenumber As String
Dim QUOTE As String

Dim user As String
user = Application.UserName
MainMenu.Hide

Application.ScreenUpdating = False 'Keeps screen from updating thereby
speeding routine
Application.DisplayAlerts = False

quotenumber = InputBox("Please enter QUOTE number to recall from your
hard drive. If recalling a quote from the server" & _
"type in \\server3\jobs\estimate1\quickquotes3\ and the quote number.")
QUOTE = "C:\Quick Quotes3\" & quotenumber & ".XLS"
On Error GoTo ehandler

Workbooks.Open Filename:=QUOTE
ActiveWorkbook.SaveAs Filename:="TempData.xls"

Windows("TempData.XLS").Activate 'Recalls input saved data
Range("A2:A36").Select
Selection.Copy

This is were I want to check the last 2 letters

Windows(MasterSheet).Activate
Range("AB2").Select
Selection.PasteSpecial Paste:=xlValues

etc


You could use the same algorithm as in the worksheet function with something
like:

=========================
....
For Each c In Range("AB2:AB36")
Select Case Right(c.Value, 2)
Case "AB", "CD", "EF" 'etc
c.Value = Left(c.Value, Len(c.Value) - 2)
End Select
Next c
....
--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Cut off end of a string

Sorry I didn't show the correct code. I have edited the code below


"Ron Rosenfeld" wrote:

On Tue, 3 Mar 2009 15:39:36 -0800, Oldjay
wrote:

This is my code

Private Sub CommandButton22_Click() 'Recalls a quote

Dim quotenumber As String
Dim QUOTE As String

Dim user As String
user = Application.UserName
MainMenu.Hide

Application.ScreenUpdating = False 'Keeps screen from updating thereby
speeding routine
Application.DisplayAlerts = False

quotenumber = InputBox("Please enter QUOTE number to recall from your
hard drive. If recalling a quote from the server" & _
"type in \\server3\jobs\estimate1\quickquotes3\ and the quote number.")
QUOTE = "C:\Quick Quotes3\" & quotenumber & ".XLS"
On Error GoTo ehandler

Workbooks.Open Filename:=QUOTE
ActiveWorkbook.SaveAs Filename:="TempData.xls"

Windows("TempData.XLS").Activate 'Recalls quote number
Range("A2").Select
Selection.Copy

This is were I want to check the last 2 letters against a list of initials. If they are on the list then delete them.

Windows(MasterSheet).Activate
Range("AB2").Select
Selection.PasteSpecial Paste:=xlValues

etc


You could use the same algorithm as in the worksheet function with something
like:

=========================
....
For Each c In Range("AB2:AB36")
Select Case Right(c.Value, 2)
Case "AB", "CD", "EF" 'etc
c.Value = Left(c.Value, Len(c.Value) - 2)
End Select
Next c
....
--ron

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Cut off end of a string

On Tue, 3 Mar 2009 18:25:02 -0800, Oldjay
wrote:

For Each c In Range("AB2:AB36")
Select Case Right(c.Value, 2)
Case "AB", "CD", "EF" 'etc
c.Value = Left(c.Value, Len(c.Value) - 2)
End Select
Next c


Well, if you're only checking AB2, then simply:

with range("ab2")
select case right(.value,2)
case "ab", "cd", "ef" 'etc
.value = left(.value,len(.value)-2)
end select
end with
--ron
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
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
Replace Hyperlink Addresses Help 'Dim OldStr As String, NewStr As String Ron[_14_] Excel Programming 6 January 23rd 07 07:38 PM
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) Brian Excel Programming 3 February 9th 06 03:38 PM
Importing Long String - String Manipulation (EDI EANCOM 96a) Brian Excel Programming 6 February 9th 06 12:27 PM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


All times are GMT +1. The time now is 09:10 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"