Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default VBA code or formula needed to identify certain records in a database

I'm drawing a blank on this one.

I have an Excel database made up of 24 columns (representing numeric
fields) and approximately 2500 rows. Each record will have a value in
at least one of the 24 fields and can have values in up to all 24
fields. I am to create a 25th field (called "ID") in which an "x" is
placed if a record meets the following criteria:

1.) It must have values in at least 2 of the 24 fields, and
2.) At least 1 of the fields with a value in it is not contiguous with
another field with a value in it.

In other words, to qualify for an "x", at least 2 fields have numbers
and there is a gap separating at least one of those fields.

Here's a simplified version:


Field1 Field2 Field3 Field4 Field5 ID
------------------------------------------
12
------------------------------------------
3 14 x
------------------------------------------
1 5
------------------------------------------
7 8 12 x
------------------------------------------
2 3
------------------------------------------
6 5 4 x
------------------------------------------
8 7 1 12 14
------------------------------------------
7 8 10 11 x
------------------------------------------


Either a macro solution or a formula solution to getting the "x" is
fine, and if "helper" columns are needed, that's fine, too.

Many thanks,
Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default VBA code or formula needed to identify certain records in a database

Dick,

Thank you very much for your considerable time and effort. This was a
big help, and I appreciate the work you put in on it for me very much.

Many thanks,
Paul



"Dick Kusleika" wrote in message ...
Paul

For this worksheet formula, you will need two dummy columns on either end of
the 24 columns of data. The dummy columns must contain values. My formula
is in A1, the dummy columns are B and AA and the data is in C1:Z1. Array
enter this formula with control+shift+enter

=IF(COUNT(C1:Z1)1,IF(SUM((C1:Z1<"")*(B1:Y1="")*( D1:AA1=""))0,"selected","
"),"")

I didn't test all the combinations of columns, but I think it's right. Let
me know if you find a mistake.

For this UDF, you don't need dummy columns, just the code below

=IF(isselected(C1:Z1),"selected","")

Function IsSelected(Rng As Range) As Boolean

Dim cell As Range
Dim FirstCol As Long
Dim LastCol As Long

FirstCol = Rng.Cells(1).Column
LastCol = Rng.Cells(Rng.Count).Column

If Application.Count(Rng) 1 Then
For Each cell In Rng.Cells
If Not IsEmpty(cell) Then
Select Case cell.Column
Case FirstCol
If IsEmpty(cell.Offset(0, 1)) Then
IsSelected = True
Exit Function
End If
Case LastCol
If IsEmpty(cell.Offset(0, -1)) Then
IsSelected = True
Exit Function
End If
Case Else
If IsEmpty(cell.Offset(0, 1)) And _
IsEmpty(cell.Offset(0, -1)) Then

IsSelected = True
Exit Function
End If
End Select
End If
Next cell
End If

IsSelected = False

End Function

Let me know if they don't suit your needs.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Paul Simon" wrote in message
om...
I'm drawing a blank on this one.

I have an Excel database made up of 24 columns (representing numeric
fields) and approximately 2500 rows. Each record will have a value in
at least one of the 24 fields and can have values in up to all 24
fields. I am to create a 25th field (called "ID") in which an "x" is
placed if a record meets the following criteria:

1.) It must have values in at least 2 of the 24 fields, and
2.) At least 1 of the fields with a value in it is not contiguous with
another field with a value in it.

In other words, to qualify for an "x", at least 2 fields have numbers
and there is a gap separating at least one of those fields.

Here's a simplified version:


Field1 Field2 Field3 Field4 Field5 ID
------------------------------------------
12
------------------------------------------
3 14 x
------------------------------------------
1 5
------------------------------------------
7 8 12 x
------------------------------------------
2 3
------------------------------------------
6 5 4 x
------------------------------------------
8 7 1 12 14
------------------------------------------
7 8 10 11 x
------------------------------------------


Either a macro solution or a formula solution to getting the "x" is
fine, and if "helper" columns are needed, that's fine, too.

Many thanks,
Paul

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
Macro needed to identify value and delete row if value below targe Pyrotoy New Users to Excel 3 December 9th 08 11:35 PM
How to identify when similar records appear in two sets of data dr_elb_99 Excel Discussion (Misc queries) 1 May 2nd 08 10:19 PM
Code needed to find records from bottom up Andy Excel Discussion (Misc queries) 4 December 5th 05 03:27 AM
compare two spreadsheets and identify records that have any change brenped Excel Discussion (Misc queries) 2 May 6th 05 02:09 PM
formula / code help needed Paul Watkins Excel Discussion (Misc queries) 2 March 16th 05 08:27 PM


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