Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Select value on a cell by matching value of two cells

I am in need of a macro to select the value based on two columns
value.

Below is the sample spreadsheet where my datas are arranged:

Column A Column B Column C
(City) (County)
(Factor)
ABBEVILLE HENRY 06
ABBEVILLE FD HENRY 06
ABERNANT CSA TUSCALOOSA 07
ABERNATHY CSA CLEBURNE 09
ADAMSBURG CSA DEKALB 05
ADAMSBURG CSA CHEROKEE 10
ADAMSVILLE JEFFERSON 01
ADDISON WINSTON 06
ADDISON FD WINSTON 06
ALTOONA ETOWAH 01
ALTOONA BLOUNT 07

For eg, for city "ALTOONA" and county "BLOUNT", the factor value
should return as "07". The factor value should return based on the
match of both A and B cell value.

Please help me by posting the macro for above scenario.

Thanks,
Maniarasan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Select value on a cell by matching value of two cells

On 12/07/2010 14:22, maniarasan wrote:
I am in need of a macro to select the value based on two columns
value.

Below is the sample spreadsheet where my datas are arranged:

Column A Column B Column C
(City) (County)
(Factor)
ABBEVILLE HENRY 06
ABBEVILLE FD HENRY 06
ABERNANT CSA TUSCALOOSA 07
ABERNATHY CSA CLEBURNE 09
ADAMSBURG CSA DEKALB 05
ADAMSBURG CSA CHEROKEE 10
ADAMSVILLE JEFFERSON 01
ADDISON WINSTON 06
ADDISON FD WINSTON 06
ALTOONA ETOWAH 01
ALTOONA BLOUNT 07

For eg, for city "ALTOONA" and county "BLOUNT", the factor value
should return as "07". The factor value should return based on the
match of both A and B cell value.

Please help me by posting the macro for above scenario.

Thanks,
Maniarasan


Not really sure that this is what you are looking for:

I've implemented a function to return the value in column C if a match
is found in columns A & B.
Note that only the first match is returned - based on your post I assume
that the matches in A & B are always unique.

Call the Function with

=Factor("String to find in first Column", "String to find in 2nd
Column", Range to search in First Column)

If there is no match zero is returned.

Function Factor(A As String, B As String, C As Range) As Variant
Dim D As Range

Application.Volatile True

For Each D In C
If D.Value = A Then
If D.Offset(0, 1) = B Then
Factor = D.Offset(0, 2)
Exit Function
End If
Else
Factor = 0
End If
Next D
End Function

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
Select all Matching cells Lindsey Excel Programming 0 June 16th 08 05:43 PM
Select matching records from list Anthony Excel Worksheet Functions 3 May 17th 07 02:05 PM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
Finding matching cells between two workborks and updating cell con tukky142 Excel Worksheet Functions 2 February 26th 07 11:27 AM
select only non-matching rows fuzzy Excel Programming 1 August 23rd 05 03:50 PM


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