Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default extract right side of string

Morning all.

I have a data set that I want to extract the right side from.
Here's an example of the data.

02-243-02 - 0.14
02-243-03 - 0.16
.........
......
.......
where the periods are the continuation of the 7 digits, and the numeric
values to the right. The data set is approx.
100 items, and I'd like to place the numeric values in the cell to the right
of the 7 digit numbers on the left.

I've tried the following, and get a type mismatch error.

Sub ExtractRight()
v = ActiveCell.value
s = Right(v, 4)
For i = LBound(s) To UBound(s)
ActiveCell.Offset(i + 1, 1).value = s(i)
Next
End Sub

I'm figuring that I get the error because right() and my limits don't work
with each other.

How can I accomplish my goal?
Thank you.
Best,
SteveB.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default extract right side of string

Sub steve()
Dim v As String, val As Double
v = ActiveCell.Value
val = Right(v, 4)
ActiveCell.Offset(0, 1).Value = val
End Sub
--
Gary''s Student - gsnu200812


"SteveDB1" wrote:

Morning all.

I have a data set that I want to extract the right side from.
Here's an example of the data.

02-243-02 - 0.14
02-243-03 - 0.16
........
.....
......
where the periods are the continuation of the 7 digits, and the numeric
values to the right. The data set is approx.
100 items, and I'd like to place the numeric values in the cell to the right
of the 7 digit numbers on the left.

I've tried the following, and get a type mismatch error.

Sub ExtractRight()
v = ActiveCell.value
s = Right(v, 4)
For i = LBound(s) To UBound(s)
ActiveCell.Offset(i + 1, 1).value = s(i)
Next
End Sub

I'm figuring that I get the error because right() and my limits don't work
with each other.

How can I accomplish my goal?
Thank you.
Best,
SteveB.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default extract right side of string

Gary's Student,
Thank you for the response.
It does work, now what will it take to repeat it to the end of my data?

I have approximately 100 data points that I need to repeat this to the end of.

I tried placing a

for i = 1 to range(activecell.column).end(xldown)

and it returns an error- method of range object- global failed.

Thank you for your help.


"Gary''s Student" wrote:

Sub steve()
Dim v As String, val As Double
v = ActiveCell.Value
val = Right(v, 4)
ActiveCell.Offset(0, 1).Value = val
End Sub
--
Gary''s Student - gsnu200812


"SteveDB1" wrote:

Morning all.

I have a data set that I want to extract the right side from.
Here's an example of the data.

02-243-02 - 0.14
02-243-03 - 0.16
........
.....
......
where the periods are the continuation of the 7 digits, and the numeric
values to the right. The data set is approx.
100 items, and I'd like to place the numeric values in the cell to the right
of the 7 digit numbers on the left.

I've tried the following, and get a type mismatch error.

Sub ExtractRight()
v = ActiveCell.value
s = Right(v, 4)
For i = LBound(s) To UBound(s)
ActiveCell.Offset(i + 1, 1).value = s(i)
Next
End Sub

I'm figuring that I get the error because right() and my limits don't work
with each other.

How can I accomplish my goal?
Thank you.
Best,
SteveB.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default extract right side of string

Select the top cell to be processed and:

Sub steve()
Dim v As String, val As Double
While ActiveCell.Value < ""
v = ActiveCell.Value
val = Right(v, 4)
ActiveCell.Offset(0, 1).Value = val
ActiveCell.Offset(1, 0).Select
Wend
End Sub
--
Gary''s Student - gsnu200812


"SteveDB1" wrote:

Gary's Student,
Thank you for the response.
It does work, now what will it take to repeat it to the end of my data?

I have approximately 100 data points that I need to repeat this to the end of.

I tried placing a

for i = 1 to range(activecell.column).end(xldown)

and it returns an error- method of range object- global failed.

Thank you for your help.


"Gary''s Student" wrote:

Sub steve()
Dim v As String, val As Double
v = ActiveCell.Value
val = Right(v, 4)
ActiveCell.Offset(0, 1).Value = val
End Sub
--
Gary''s Student - gsnu200812


"SteveDB1" wrote:

Morning all.

I have a data set that I want to extract the right side from.
Here's an example of the data.

02-243-02 - 0.14
02-243-03 - 0.16
........
.....
......
where the periods are the continuation of the 7 digits, and the numeric
values to the right. The data set is approx.
100 items, and I'd like to place the numeric values in the cell to the right
of the 7 digit numbers on the left.

I've tried the following, and get a type mismatch error.

Sub ExtractRight()
v = ActiveCell.value
s = Right(v, 4)
For i = LBound(s) To UBound(s)
ActiveCell.Offset(i + 1, 1).value = s(i)
Next
End Sub

I'm figuring that I get the error because right() and my limits don't work
with each other.

How can I accomplish my goal?
Thank you.
Best,
SteveB.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default extract right side of string

bingo.....
Another satisfied customer-- thank you.


"Gary''s Student" wrote:

Select the top cell to be processed and:

Sub steve()
Dim v As String, val As Double
While ActiveCell.Value < ""
v = ActiveCell.Value
val = Right(v, 4)
ActiveCell.Offset(0, 1).Value = val
ActiveCell.Offset(1, 0).Select
Wend
End Sub
--
Gary''s Student - gsnu200812


"SteveDB1" wrote:

Gary's Student,
Thank you for the response.
It does work, now what will it take to repeat it to the end of my data?

I have approximately 100 data points that I need to repeat this to the end of.

I tried placing a

for i = 1 to range(activecell.column).end(xldown)

and it returns an error- method of range object- global failed.

Thank you for your help.


"Gary''s Student" wrote:

Sub steve()
Dim v As String, val As Double
v = ActiveCell.Value
val = Right(v, 4)
ActiveCell.Offset(0, 1).Value = val
End Sub
--
Gary''s Student - gsnu200812


"SteveDB1" wrote:

Morning all.

I have a data set that I want to extract the right side from.
Here's an example of the data.

02-243-02 - 0.14
02-243-03 - 0.16
........
.....
......
where the periods are the continuation of the 7 digits, and the numeric
values to the right. The data set is approx.
100 items, and I'd like to place the numeric values in the cell to the right
of the 7 digit numbers on the left.

I've tried the following, and get a type mismatch error.

Sub ExtractRight()
v = ActiveCell.value
s = Right(v, 4)
For i = LBound(s) To UBound(s)
ActiveCell.Offset(i + 1, 1).value = s(i)
Next
End Sub

I'm figuring that I get the error because right() and my limits don't work
with each other.

How can I accomplish my goal?
Thank you.
Best,
SteveB.

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
to extract numeric figures in left side od the alpha charectors pl pol Excel Discussion (Misc queries) 1 August 20th 08 08:29 AM
VBA string funcs on left side of assignment? [email protected] Excel Programming 5 July 17th 08 08:29 AM
How do I extract the numbers from the right side of the cell Dave L[_2_] Excel Discussion (Misc queries) 2 June 29th 07 09:58 PM
extract string owl527[_7_] Excel Programming 3 November 4th 05 10:35 AM
Extract sub string sixbeforedawn Excel Worksheet Functions 2 October 24th 05 09:50 AM


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

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"