PC Review


Reply
Thread Tools Rate Thread

Compare Column to Inbput Box Variable

 
 
=?Utf-8?B?R3JhbmRNYU1h?=
Guest
Posts: n/a
 
      4th Jul 2007
User's Group

This is only the second time I have ever worked with Excel so please have
patience.

I need to enter Filtering Criteria from an Input Box.

Then match the contents of that variable to Column L (Will always be Column L)

Because of what I eventually have to do I cannot use Autofilter.

TestClass = InputBox("Enter ACT, International, S.A.T. or TAKS
Classification")

? = What is the Format(Syntax) to compare the contents of TestClass to
Column L.

There will be eventually more code, I have to convert from another software
application (That I have little knowledge of) to Excel.

Thanks to all of ya' for assistance

Granny

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxhdGhhbQ==?=
Guest
Posts: n/a
 
      4th Jul 2007
It's difficult to give you "the" answer without knowing how you want to
handle matches. You say you can't use AutoFilter, so we'll just assume you
want matched cells 'noticed' for the moment. This code physically moves cell
to cell down the column - there are definitely more efficient, faster ways to
do this with Range objects, but since this is 2nd time out for you <g>.

Dim lastRow as Long

'you get your TestClass value as before here

lastRow = Range("L" & Rows.Count).End(xlUp).Row
'if using Excel 2007, substitute:
lastRow = Range("L" & Rows.CountLarge).End(xlUp).Row
Range("L1").Select
Do Until ActiveCell.Row > lastRow
If ActiveCell.Value = TestClass Then
'code to process matched data here
End If
ActiveCell.Offset(1, 0).Activate ' move to next row
Loop


"GrandMaMa" wrote:

> User's Group
>
> This is only the second time I have ever worked with Excel so please have
> patience.
>
> I need to enter Filtering Criteria from an Input Box.
>
> Then match the contents of that variable to Column L (Will always be Column L)
>
> Because of what I eventually have to do I cannot use Autofilter.
>
> TestClass = InputBox("Enter ACT, International, S.A.T. or TAKS
> Classification")
>
> ? = What is the Format(Syntax) to compare the contents of TestClass to
> Column L.
>
> There will be eventually more code, I have to convert from another software
> application (That I have little knowledge of) to Excel.
>
> Thanks to all of ya' for assistance
>
> Granny
>

 
Reply With Quote
 
=?Utf-8?B?R3JhbmRNYU1h?=
Guest
Posts: n/a
 
      4th Jul 2007
J. Latham;
Thanks for getting back. Earlier I needed some
recommendations, but no one got back to me. I will be need to print a report
on selected students. The first criteria is to select all of the test
criteria. With your help I have part of the first step completed. There are
15 more conditions I must test for.

Question: Is it better to create another work sheet or just select the
students I need from my current work sheet? Naturally I do not want to
change any information in the worksheet, just get a print out of the selected
students.

Also is there a way I can use the AutoFilter in a Macro?

If you are wondering why, the software vendor we have used for the past 15
years is going out of business. We are also converting from an IBM system to
individuals PC's for the Guidance Department.

Thanks Again;

Granny

"JLatham" wrote:

> It's difficult to give you "the" answer without knowing how you want to
> handle matches. You say you can't use AutoFilter, so we'll just assume you
> want matched cells 'noticed' for the moment. This code physically moves cell
> to cell down the column - there are definitely more efficient, faster ways to
> do this with Range objects, but since this is 2nd time out for you <g>.
>
> Dim lastRow as Long
>
> 'you get your TestClass value as before here
>
> lastRow = Range("L" & Rows.Count).End(xlUp).Row
> 'if using Excel 2007, substitute:
> lastRow = Range("L" & Rows.CountLarge).End(xlUp).Row
> Range("L1").Select
> Do Until ActiveCell.Row > lastRow
> If ActiveCell.Value = TestClass Then
> 'code to process matched data here
> End If
> ActiveCell.Offset(1, 0).Activate ' move to next row
> Loop
>
>
> "GrandMaMa" wrote:
>
> > User's Group
> >
> > This is only the second time I have ever worked with Excel so please have
> > patience.
> >
> > I need to enter Filtering Criteria from an Input Box.
> >
> > Then match the contents of that variable to Column L (Will always be Column L)
> >
> > Because of what I eventually have to do I cannot use Autofilter.
> >
> > TestClass = InputBox("Enter ACT, International, S.A.T. or TAKS
> > Classification")
> >
> > ? = What is the Format(Syntax) to compare the contents of TestClass to
> > Column L.
> >
> > There will be eventually more code, I have to convert from another software
> > application (That I have little knowledge of) to Excel.
> >
> > Thanks to all of ya' for assistance
> >
> > Granny
> >

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      4th Jul 2007
Turn on the macro recorder (tools=>macro=>record a new macro). Choose this
workbook for the location.

apply the autofilter manually.

Turn off the macro recorder by repeating the above or if the floating
toolbar has been produced, use that.

now go to the VBE and examine the code.

It will show you how to apply an autofilter using code.

If you have multiple complex conditions, it is often useful to put a formula
in the next available column that can evaluate several conditions to return a
true or false to indicate if that row should be included or not.

If you are doing this in code, you can set up all the conditions, then use a
technique such as JLatham has shown or autofilter on that column(s).

The advanced filter can allow you to specify multiple conditions, however,
another way may be to copy all the data to another sheet, then continue to
cull it down as conditions are specified (delete rows that don't meet that
condition - assume all conditions are AND related).

The alternative to copying to another sheet and would be to hide rows in the
exitsting sheet. I don't think it really matters one way or another whethe
you do it inplace or copy to another sheet. Obviously working on a copy
means the original should never get contaminated.

--
Regards,
Tom Ogilvy




"GrandMaMa" wrote:

> J. Latham;
> Thanks for getting back. Earlier I needed some
> recommendations, but no one got back to me. I will be need to print a report
> on selected students. The first criteria is to select all of the test
> criteria. With your help I have part of the first step completed. There are
> 15 more conditions I must test for.
>
> Question: Is it better to create another work sheet or just select the
> students I need from my current work sheet? Naturally I do not want to
> change any information in the worksheet, just get a print out of the selected
> students.
>
> Also is there a way I can use the AutoFilter in a Macro?
>
> If you are wondering why, the software vendor we have used for the past 15
> years is going out of business. We are also converting from an IBM system to
> individuals PC's for the Guidance Department.
>
> Thanks Again;
>
> Granny
>
> "JLatham" wrote:
>
> > It's difficult to give you "the" answer without knowing how you want to
> > handle matches. You say you can't use AutoFilter, so we'll just assume you
> > want matched cells 'noticed' for the moment. This code physically moves cell
> > to cell down the column - there are definitely more efficient, faster ways to
> > do this with Range objects, but since this is 2nd time out for you <g>.
> >
> > Dim lastRow as Long
> >
> > 'you get your TestClass value as before here
> >
> > lastRow = Range("L" & Rows.Count).End(xlUp).Row
> > 'if using Excel 2007, substitute:
> > lastRow = Range("L" & Rows.CountLarge).End(xlUp).Row
> > Range("L1").Select
> > Do Until ActiveCell.Row > lastRow
> > If ActiveCell.Value = TestClass Then
> > 'code to process matched data here
> > End If
> > ActiveCell.Offset(1, 0).Activate ' move to next row
> > Loop
> >
> >
> > "GrandMaMa" wrote:
> >
> > > User's Group
> > >
> > > This is only the second time I have ever worked with Excel so please have
> > > patience.
> > >
> > > I need to enter Filtering Criteria from an Input Box.
> > >
> > > Then match the contents of that variable to Column L (Will always be Column L)
> > >
> > > Because of what I eventually have to do I cannot use Autofilter.
> > >
> > > TestClass = InputBox("Enter ACT, International, S.A.T. or TAKS
> > > Classification")
> > >
> > > ? = What is the Format(Syntax) to compare the contents of TestClass to
> > > Column L.
> > >
> > > There will be eventually more code, I have to convert from another software
> > > application (That I have little knowledge of) to Excel.
> > >
> > > Thanks to all of ya' for assistance
> > >
> > > Granny
> > >

 
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
HELP: Compare Column values with column names in different tables sam Microsoft Access Form Coding 4 26th May 2010 07:56 PM
compare data in column A with column B to find duplicates George Microsoft Excel Misc 8 6th Feb 2009 03:53 PM
compare cells in column to criteria, then average next column cell Bradwin Microsoft Excel Worksheet Functions 2 21st Jul 2008 08:37 PM
compare data from one column with another and compare result to yet another Matt Williamson Microsoft Excel Programming 1 25th Sep 2003 08:54 PM
compare data from one column with another and compare result to yet another Matt Williamson Microsoft Excel Worksheet Functions 1 25th Sep 2003 08:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:34 PM.