Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
JBS JBS is offline
external usenet poster
 
Posts: 11
Default search and return adjacent value

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default search and return adjacent value

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #3   Report Post  
Posted to microsoft.public.excel.misc
JBS JBS is offline
external usenet poster
 
Posts: 11
Default search and return adjacent value

Yes, it is a comma delimited file which imports into onecell per row in
Excel. I can change it to be by doing "text to Data"

3010 123456789 4103 123.56 5101 123
3010 987654321 3011 abcde 4103 15000.00 5103 654
3010 654987321 4103 4523.69 5104 987

the result I am looking for would be

123456789 123.56
987654321 15000.00
654987321 4523.69




"FSt1" wrote:

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default search and return adjacent value

hi,
would be better. where do you want the results? next sheet?

"JBS" wrote:

Yes, it is a comma delimited file which imports into onecell per row in
Excel. I can change it to be by doing "text to Data"

3010 123456789 4103 123.56 5101 123
3010 987654321 3011 abcde 4103 15000.00 5103 654
3010 654987321 4103 4523.69 5104 987

the result I am looking for would be

123456789 123.56
987654321 15000.00
654987321 4523.69




"FSt1" wrote:

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #5   Report Post  
Posted to microsoft.public.excel.misc
JBS JBS is offline
external usenet poster
 
Posts: 11
Default search and return adjacent value

Yes please, or in column A and B of the existing sheet if that is easier?

"FSt1" wrote:

hi,
would be better. where do you want the results? next sheet?

"JBS" wrote:

Yes, it is a comma delimited file which imports into onecell per row in
Excel. I can change it to be by doing "text to Data"

3010 123456789 4103 123.56 5101 123
3010 987654321 3011 abcde 4103 15000.00 5103 654
3010 654987321 4103 4523.69 5104 987

the result I am looking for would be

123456789 123.56
987654321 15000.00
654987321 4523.69




"FSt1" wrote:

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default search and return adjacent value

Try this in B1 and drag down.

=MID(A1,FIND(4103,A1,1)+5,(FIND(",",A1,FIND(4103,A 1,1)+5))-(FIND(4103,A1,1)+5))

Mike

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default search and return adjacent value

hi,
About half done. need to adjust based on your last post and add loop. hold
on. working.
how big is the import?

FSt1
"JBS" wrote:

Yes please, or in column A and B of the existing sheet if that is easier?

"FSt1" wrote:

hi,
would be better. where do you want the results? next sheet?

"JBS" wrote:

Yes, it is a comma delimited file which imports into onecell per row in
Excel. I can change it to be by doing "text to Data"

3010 123456789 4103 123.56 5101 123
3010 987654321 3011 abcde 4103 15000.00 5103 654
3010 654987321 4103 4523.69 5104 987

the result I am looking for would be

123456789 123.56
987654321 15000.00
654987321 4523.69




"FSt1" wrote:

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default search and return adjacent value

hi.
sorry it took so long. I add text to columns. use if you want.
macro adds a sheet named results.
edit to fit your data.
Sub findstuff()
'Sheets("Sheet1").Select
'Range("A2:A4000").Select
'Selection.TextToColumns Destination:=Range("A2"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), _
Array(6, 1),Array(7, 1), Array(8, 1)), TrailingMinusNumbers:=True
'Cells.AutoFit
Sheets.Add.Name = "Results"
Sheets("Sheet1").Select 'change if needed
Dim f As String
Dim ba As Range
Dim bb As Range
Dim bc As Range
Dim bd As Range
Dim r As Range
Set ba = Range("B2")
Set bc = Sheets("Results").Range("A2") 'destination 1
Application.CutCopyMode = False
ba.Copy
bc.PasteSpecial xlPasteAll
f = InputBox("Enter something to find.")
Do While Not IsEmpty(ba)
Set bb = ba.Offset(1, 0)
Set bd = bc.Offset(1, 0)
ba.Copy
bc.PasteSpecial xlPasteAll
On Error Resume Next
Set sr = Range(ba.Offset(0, -1), ba.Offset(0, -1).End(xlToRight))
sr.Select
If f < "" Then
Set r = Nothing
Set r = sr.Find(What:=f, After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End If
If r Is Nothing Then
Set bc = Nothing
Else
Application.CutCopyMode = False
r.Offset(0, 1).Copy
bc.Offset(0, 1).PasteSpecial xlPasteAll
End If
Set ba = bb
Set bc = bd
Loop

End Sub

test on your test data. works on xp2003

regards
FSt1
"FSt1" wrote:

hi,
About half done. need to adjust based on your last post and add loop. hold
on. working.
how big is the import?

FSt1
"JBS" wrote:

Yes please, or in column A and B of the existing sheet if that is easier?

"FSt1" wrote:

hi,
would be better. where do you want the results? next sheet?

"JBS" wrote:

Yes, it is a comma delimited file which imports into onecell per row in
Excel. I can change it to be by doing "text to Data"

3010 123456789 4103 123.56 5101 123
3010 987654321 3011 abcde 4103 15000.00 5103 654
3010 654987321 4103 4523.69 5104 987

the result I am looking for would be

123456789 123.56
987654321 15000.00
654987321 4523.69




"FSt1" wrote:

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

  #9   Report Post  
Posted to microsoft.public.excel.misc
JBS JBS is offline
external usenet poster
 
Posts: 11
Default search and return adjacent value

Thank you. Will test today. Thanks again for your time

"FSt1" wrote:

hi.
sorry it took so long. I add text to columns. use if you want.
macro adds a sheet named results.
edit to fit your data.
Sub findstuff()
'Sheets("Sheet1").Select
'Range("A2:A4000").Select
'Selection.TextToColumns Destination:=Range("A2"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
1), _
Array(6, 1),Array(7, 1), Array(8, 1)), TrailingMinusNumbers:=True
'Cells.AutoFit
Sheets.Add.Name = "Results"
Sheets("Sheet1").Select 'change if needed
Dim f As String
Dim ba As Range
Dim bb As Range
Dim bc As Range
Dim bd As Range
Dim r As Range
Set ba = Range("B2")
Set bc = Sheets("Results").Range("A2") 'destination 1
Application.CutCopyMode = False
ba.Copy
bc.PasteSpecial xlPasteAll
f = InputBox("Enter something to find.")
Do While Not IsEmpty(ba)
Set bb = ba.Offset(1, 0)
Set bd = bc.Offset(1, 0)
ba.Copy
bc.PasteSpecial xlPasteAll
On Error Resume Next
Set sr = Range(ba.Offset(0, -1), ba.Offset(0, -1).End(xlToRight))
sr.Select
If f < "" Then
Set r = Nothing
Set r = sr.Find(What:=f, After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End If
If r Is Nothing Then
Set bc = Nothing
Else
Application.CutCopyMode = False
r.Offset(0, 1).Copy
bc.Offset(0, 1).PasteSpecial xlPasteAll
End If
Set ba = bb
Set bc = bd
Loop

End Sub

test on your test data. works on xp2003

regards
FSt1
"FSt1" wrote:

hi,
About half done. need to adjust based on your last post and add loop. hold
on. working.
how big is the import?

FSt1
"JBS" wrote:

Yes please, or in column A and B of the existing sheet if that is easier?

"FSt1" wrote:

hi,
would be better. where do you want the results? next sheet?

"JBS" wrote:

Yes, it is a comma delimited file which imports into onecell per row in
Excel. I can change it to be by doing "text to Data"

3010 123456789 4103 123.56 5101 123
3010 987654321 3011 abcde 4103 15000.00 5103 654
3010 654987321 4103 4523.69 5104 987

the result I am looking for would be

123456789 123.56
987654321 15000.00
654987321 4523.69




"FSt1" wrote:

how is this data layed out? All in one cell?
FSt1

"JBS" wrote:

I have a file as follows
3010,123456789,4103,123.56,5101,123
3010,987654321,3011,abcde,4103,15000.00,5103,654
3010,654987321,4103,4523.69,5104,987

I need to search for the value 4103 and return the value after it eg. 123.56

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 do i referance an adjacent cell from a search? UH-60 Crew Chief Excel Discussion (Misc queries) 4 May 18th 07 08:35 PM
Return adjacent cell if conditional formatting exists. Donna Excel Worksheet Functions 12 November 10th 06 04:34 AM
Return value in adjacent cell TammyS Excel Worksheet Functions 5 August 30th 06 08:13 PM
return value in adjacent cell different workbook Don D Excel Worksheet Functions 4 May 2nd 06 11:37 PM
test a range of cells and return an adjacent value whub3 Excel Worksheet Functions 5 April 20th 06 01:04 AM


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