Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Index & Match w/ VBA

I have a helper sheet called "counties". In it is a list of all the counties
in Illinois (column A) and the district they belong in (column B). I have a
small macro that converts a .csv file to the format that I like, but i'd
also like for it to look in Column F of the Data Sheet, match the county and
insert the corresponding district in Column G.

Anyone help me out with this? Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Index & Match w/ VBA

assuming that counties column A is alpha sorted
assume 132 counties

Formula in say - Cell G6 Then copy down

=Vlookup(F6,counties!A1:B132,2,False)

Vote Republican!

"Dominique Feteau" wrote:

I have a helper sheet called "counties". In it is a list of all the counties
in Illinois (column A) and the district they belong in (column B). I have a
small macro that converts a .csv file to the format that I like, but i'd
also like for it to look in Column F of the Data Sheet, match the county and
insert the corresponding district in Column G.

Anyone help me out with this? Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Index & Match w/ VBA

Dim rng as Range, rng1 as Range
Dim cell as Range, res as Variant
With Worksheets("Data")
set rng = .Range(.Cells(2,"F"),.Cells(rows.count,"F").End(xl up))
end with

With Workbooks("CountyList.xls").Worksheets("Counties")
set rng1 = .Range(.Cells(2,1).Cells(2,1).End(xldown))
End With

for each cell in rng
res = application.match(cell.Value, rng1,0)
if not iserror(res) then
cell.offset(0,1).Value = rng1(res,2).Value
end if
Next

--
Regards,
Tom Ogilvy


"Dominique Feteau" wrote in message
...
I have a helper sheet called "counties". In it is a list of all the

counties
in Illinois (column A) and the district they belong in (column B). I have

a
small macro that converts a .csv file to the format that I like, but i'd
also like for it to look in Column F of the Data Sheet, match the county

and
insert the corresponding district in Column G.

Anyone help me out with this? Thanks




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
Find Exact Match using INDEX, MATCH DoubleUU Excel Worksheet Functions 3 August 15th 08 02:42 PM
index(match) Wind Uplift Calculations (match four conditions) JMeier Excel Worksheet Functions 8 August 1st 08 01:45 AM
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 AM
How do I display more than one match in a Index/Match formula? Trish Excel Worksheet Functions 0 September 26th 05 10:21 PM
index,match,match on un-sorted data Brisbane Rob Excel Worksheet Functions 3 September 24th 05 10:04 PM


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