Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default search in a list, then replace using 1st column always

This is the solution i got to work....
'////////////////////////////////////////////////////////////////
Dim x, FinalRow, rw As Long
Dim w As Worksheet
Dim s, r
Dim rng As Range
FinalRow = Cells(Rows.Count, 4).End(xlUp).Row
rw = Sheets("Project").Cells(65500, 1).End(xlUp).Row
Set w = Sheets("Project")
Dim MyColumn As String, Here As String
Set rng = w.Range("A2:B" & rw)
For x = 2 To FinalRow
Cells(x, 6).Select
s = Cells(x, 4).Value
If Cells(x, 6).Value = "" Then
For Each r In rng
If r.Value = s Then
'Cells(x, 6).Value = r.Value
Cells(x, 7).Value = r.Address
Cells(x, 6).Formula = "=VLOOKUP(" & Cells(x, 4).Address &
_
", ProjectList,3,True)"
Here = r.Address
MyColumn = Mid(Here, InStr(Here, "$") + 1, InStr(2, Here,
"$") - 2)
If MyColumn = "B" Then
'MsgBox "my column = B"
Cells(x, 4).Clear
Cells(x, 4).Value = r.Offset(0, -1).Value
Cells(x, 6).Formula = "=VLOOKUP(" & Cells(x, 4).Address
& _
", ProjectList,3,True)"
End If
Exit For
End If
Next r
End If
Next x

'///////////////////////////////////////////////////////////////

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 to search in one column, and replace in the other column if fo Adnan Excel Discussion (Misc queries) 2 November 14th 08 01:03 PM
Find & Replace - Limit search to a specific column falena23 Excel Worksheet Functions 3 July 28th 08 03:46 PM
Column list search JRIVERA77 Excel Worksheet Functions 2 February 8th 06 06:32 PM
Value Search From a List in a Column Duncan Excel Discussion (Misc queries) 3 October 14th 05 11:30 AM
Macro to search a column for a specific word and replace with wendy Excel Programming 5 January 19th 04 05:41 PM


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