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

Hello,

I have a script who Seiya give me ones.
I use it now for a bit another purpose, so i had to adjust some things.
In sheet1 i have some names in column B, these names are also
represented in column A of sheet2. In sheet2 at Column B are some
additional infromation (names sometimes more then 1 and seperated with
a ';'). The script search for a match and copy the information to
sheet1 in column C. But when a name is more then ones represented in
Column B of sheet1 he only copy's the additional info with the first
match and skips the other matches.
Can someone tell me what i have to change in the script so he will copy
the information (column B sheet2) with every single match and not only
the first one??

Sub test()
Dim r As Range, txt, ws1 As Worksheet, ws2 As Worksheet
Dim LookUpCell As Range, x
Set ws1 = Worksheets("Sheet1"): Set ws2 = Worksheets("Sheet2")
With ws2
For Each r In .Range("a1", .Range("b65536").End(xlUp))
If Not IsEmpty(r) Then
If InStr(r, ";") = 0 Then
Set LookUpCell = ws1.Range("b:b").Find(what:=r.Value,
lookat:=xlWhole)
If Not LookUpCell Is Nothing Then
LookUpCell.Offset(, 1) = r.Offset(, 1).Value
End If


Else
txt = Split(Replace(r, " ", ""), ";")
For Each x In txt
Set LookUpCell = ws1.Range("b:b").Find(what:=x,
lookat:=xlWhole)
If Not LookUpCell Is Nothing Then
LookUpCell.Offset(, 1) = r.Offset(,
1).Value
End If


Next
End If
End If
Next
Set ws1 = Nothing: Set ws2 = Nothing: Erase txt
End With


End Sub

Chris

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
Autofill script question Gor_yee Excel Discussion (Misc queries) 2 August 4th 07 07:29 PM
question about some excel restriction script running on ... roise_r Excel Discussion (Misc queries) 0 March 30th 06 11:53 AM
question about some excel restriction script running on ... roise_r Excel Discussion (Misc queries) 0 March 30th 06 11:44 AM
excel script question -- numbers to words bronach Excel Programming 4 August 11th 04 08:12 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM


All times are GMT +1. The time now is 08:25 AM.

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"