Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Right & Split question

I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Right & Split question

What is the question?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Right & Split question

Hi Stuart

how about something like this:
If Right(C, 2) = "m2" Then

C = Left(C, Len(C) - 2)

this will over type the value in E with the original value minus the m2 bit

Cheers
JulieD

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Right & Split question

Hi Stuart
what is your actual question :-)
Do not see an error in your code. Though I would change
If Right(C, 2) = "m2" Then
x = Split(C, " ")

to
If Right(C.value, 2) = "m2" Then
x = Split(C.value, " ")


--
Regards
Frank Kabel
Frankfurt, Germany

Stuart wrote:
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Right & Split question

Ideally I need to test each cell as follows:

if the last 2 character are "m2" then copy it to col I, same row
and strip it from the 'found' cell.

Many similar checks to run, but if you would be kind enough
to example one, maybe I can solve those remaining

Regards.

----- Original Message -----
From: "Bob Phillips"
Newsgroups: microsoft.public.excel.programming
Sent: Saturday, February 28, 2004 4:38 PM
Subject: Right & Split question


What is the question?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Right & Split question

Stuart,

Here's some code

Dim C As Range

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
Select Case LCase(Right(C, 2))
Case "m2":
C.Value = Left(C.Value, Len(C.Value) - 2)
C.Cells(, 9 - C.Column + 1) = "m2"
'Case "something else":
End Select
Next
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
Ideally I need to test each cell as follows:

if the last 2 character are "m2" then copy it to col I, same row
and strip it from the 'found' cell.

Many similar checks to run, but if you would be kind enough
to example one, maybe I can solve those remaining

Regards.

----- Original Message -----
From: "Bob Phillips"
Newsgroups: microsoft.public.excel.programming
Sent: Saturday, February 28, 2004 4:38 PM
Subject: Right & Split question


What is the question?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Right & Split question

Many thanks, big help.

In the other tests, as far as I can see, the test will similarly
involve testing the end of the string in col E, but for
a different length of characters.

So I may have to test for last char 'm'
or say 'tonne'.

Is there a way to incorporate these conditions into the
Case construct, please?

regards.

"Bob Phillips" wrote in message
...
Stuart,

Here's some code

Dim C As Range

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
Select Case LCase(Right(C, 2))
Case "m2":
C.Value = Left(C.Value, Len(C.Value) - 2)
C.Cells(, 9 - C.Column + 1) = "m2"
'Case "something else":
End Select
Next
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
Ideally I need to test each cell as follows:

if the last 2 character are "m2" then copy it to col I, same row
and strip it from the 'found' cell.

Many similar checks to run, but if you would be kind enough
to example one, maybe I can solve those remaining

Regards.

----- Original Message -----
From: "Bob Phillips"
Newsgroups: microsoft.public.excel.programming
Sent: Saturday, February 28, 2004 4:38 PM
Subject: Right & Split question


What is the question?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Right & Split question

Stuart,

I think this is it

Dim C As Range

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
Select Case True
Case LCase(Right(C, 2)) = "m2":
C.Value = Left(C.Value, Len(C.Value) - 2)
C.Cells(, 9 - C.Column + 1) = "m2"
'Case "LCase(Right(C, 1)) = "something else":
End Select
Next
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
Many thanks, big help.

In the other tests, as far as I can see, the test will similarly
involve testing the end of the string in col E, but for
a different length of characters.

So I may have to test for last char 'm'
or say 'tonne'.

Is there a way to incorporate these conditions into the
Case construct, please?

regards.

"Bob Phillips" wrote in message
...
Stuart,

Here's some code

Dim C As Range

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
Select Case LCase(Right(C, 2))
Case "m2":
C.Value = Left(C.Value, Len(C.Value) - 2)
C.Cells(, 9 - C.Column + 1) = "m2"
'Case "something else":
End Select
Next
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
Ideally I need to test each cell as follows:

if the last 2 character are "m2" then copy it to col I, same row
and strip it from the 'found' cell.

Many similar checks to run, but if you would be kind enough
to example one, maybe I can solve those remaining

Regards.

----- Original Message -----
From: "Bob Phillips"
Newsgroups: microsoft.public.excel.programming
Sent: Saturday, February 28, 2004 4:38 PM
Subject: Right & Split question


What is the question?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Right & Split question

Many thanks to you all.

Regards.

"Bob Phillips" wrote in message
...
Stuart,

I think this is it

Dim C As Range

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
Select Case True
Case LCase(Right(C, 2)) = "m2":
C.Value = Left(C.Value, Len(C.Value) - 2)
C.Cells(, 9 - C.Column + 1) = "m2"
'Case "LCase(Right(C, 1)) = "something else":
End Select
Next
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
Many thanks, big help.

In the other tests, as far as I can see, the test will similarly
involve testing the end of the string in col E, but for
a different length of characters.

So I may have to test for last char 'm'
or say 'tonne'.

Is there a way to incorporate these conditions into the
Case construct, please?

regards.

"Bob Phillips" wrote in message
...
Stuart,

Here's some code

Dim C As Range

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
Select Case LCase(Right(C, 2))
Case "m2":
C.Value = Left(C.Value, Len(C.Value) - 2)
C.Cells(, 9 - C.Column + 1) = "m2"
'Case "something else":
End Select
Next
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stuart" wrote in message
...
Ideally I need to test each cell as follows:

if the last 2 character are "m2" then copy it to col I, same row
and strip it from the 'found' cell.

Many similar checks to run, but if you would be kind enough
to example one, maybe I can solve those remaining

Regards.

----- Original Message -----
From: "Bob Phillips"
Newsgroups: microsoft.public.excel.programming
Sent: Saturday, February 28, 2004 4:38 PM
Subject: Right & Split question


What is the question?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...

"Stuart" wrote in message
...
I sample cells in col E, for data that ends as "m2":
Because I do not know this data. I look for the
last 2 characters:

Dim C As Range, x As Variant

With ActiveSheet
For Each C In Intersect(Range("E:E"), ActiveSheet.UsedRange)
If Right(C, 2) = "m2" Then
x = Split(C, " ")
'do my stuff
End If
Next
End With

Help please.

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date:

26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 26/02/2004


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
A/B split testing question Tony Excel Discussion (Misc queries) 1 March 26th 11 12:43 AM
How do I remove split a split window? Norm New Users to Excel 3 July 19th 08 10:31 PM
2nd split Kevin Excel Discussion (Misc queries) 4 August 17th 07 04:47 PM
Split UPC Question MikeD1224 Excel Discussion (Misc queries) 2 February 16th 07 07:29 PM
Advanced Window Split & Freeze Question Andrew Excel Worksheet Functions 1 November 8th 04 01:50 AM


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