PC Review


Reply
Thread Tools Rate Thread

Comparing a list of Records

 
 
ttp
Guest
Posts: n/a
 
      11th Oct 2008
I need assistance comparing a list of records. Within my file, there are
records with multiple records. I want to perform the following If
statements. But, I don't know how to arrange it in Excel or Access.

If all the items in a field (column) begin with CR,
then variable = "HQ"
If all the items in a field (column) begin with DR,
then variable = 'OC"
Else variable = "N/A"
 
Reply With Quote
 
 
 
 
Code Cage Team
Guest
Posts: n/a
 
      11th Oct 2008
What is it you want to do with this variable?, do you want each record
marking with the variable or do you want the records moving to a sheet with
the variables name?, you need to give us a little more to go on.
--
Regards,
The Code Cage Team
www.thecodecage.com/forumz


"ttp" wrote:

> I need assistance comparing a list of records. Within my file, there are
> records with multiple records. I want to perform the following If
> statements. But, I don't know how to arrange it in Excel or Access.
>
> If all the items in a field (column) begin with CR,
> then variable = "HQ"
> If all the items in a field (column) begin with DR,
> then variable = 'OC"
> Else variable = "N/A"

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      11th Oct 2008

Assume the column to search is Column A with headers in Row 1.

Dim lr As Long, c As Range, iCnt As Long, jCnt As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set sRng = ActiveSheet.Range("A2:A" & lr) 'Change to actual
rCnt = sRng.Rows.Count
For Each c In sRng
If Left(Trim(c.Value),2) = CR Then
iCnt = iCnt + 1
ElseIf Left(Trim(c.Value, 2) = DR Then
jCnt = jCnt + 1
End if
Next
If rCnt = iCnt Then
myVar = HQ
ElseIf rCnt = jCnt Then
myVar = OC
Else
myVar = N/A
End If

This code is based on what you described in your
posting. While I doubt that it is really what you are
looking for. It will do what you described.




"ttp" wrote:

> I need assistance comparing a list of records. Within my file, there are
> records with multiple records. I want to perform the following If
> statements. But, I don't know how to arrange it in Excel or Access.
>
> If all the items in a field (column) begin with CR,
> then variable = "HQ"
> If all the items in a field (column) begin with DR,
> then variable = 'OC"
> Else variable = "N/A"

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      11th Oct 2008
Forgot the quotation marks.


Dim lr As Long, c As Range, iCnt As Long, jCnt As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set sRng = ActiveSheet.Range("A2:A" & lr) 'Change to actual
rCnt = sRng.Rows.Count
For Each c In sRng
If Left(Trim(c.Value),2) = "CR" Then
iCnt = iCnt + 1
ElseIf Left(Trim(c.Value, 2) = "DR" Then
jCnt = jCnt + 1
End if
Next
If rCnt = iCnt Then
myVar = "HQ"
ElseIf rCnt = jCnt Then
myVar = "OC"
Else
myVar = "N/A"
End If








"ttp" wrote:

> I need assistance comparing a list of records. Within my file, there are
> records with multiple records. I want to perform the following If
> statements. But, I don't know how to arrange it in Excel or Access.
>
> If all the items in a field (column) begin with CR,
> then variable = "HQ"
> If all the items in a field (column) begin with DR,
> then variable = 'OC"
> Else variable = "N/A"

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing Possible Like Records sherriross81 Microsoft Access Queries 5 18th Sep 2008 08:57 PM
Comparing fields and records and updating records cebAccess Microsoft Access Database Table Design 2 5th Oct 2006 02:59 PM
Need to filter all records that meet Data Validation List - list many records for one selection Cheryl Microsoft Excel Discussion 3 5th May 2004 09:21 PM
Comparing two records =?Utf-8?B?dmFk?= Microsoft Access VBA Modules 2 31st Jan 2004 08:46 AM
Comparing records Weatherhelm Microsoft Access Getting Started 2 2nd Sep 2003 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:12 AM.