ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Filter data (https://www.excelbanter.com/excel-discussion-misc-queries/29295-filter-data.html)

Murthy

Filter data
 
I want to filter the data on a sheet, basing on the value in a particular
cell - say A1.

What I have done so far is:
1) I have generated code to filter the list
2) I have provided a pick list in Cell A1
3) I have created a command button, clicking on which will execute the code
I mentioned in step (1) above.

Instead of clicking on the command button each time, is there a way to
filter the list, as soon as the value in Cell A1 is changed? Which event
should I use in my code for that?

Regards,
Murthy



Ron de Bruin

Hi Murthy

You can use the change event to run your sub.
http://www.cpearson.com/excel/events.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Murthy" wrote in message ...
I want to filter the data on a sheet, basing on the value in a particular
cell - say A1.

What I have done so far is:
1) I have generated code to filter the list
2) I have provided a pick list in Cell A1
3) I have created a command button, clicking on which will execute the code
I mentioned in step (1) above.

Instead of clicking on the command button each time, is there a way to
filter the list, as soon as the value in Cell A1 is changed? Which event
should I use in my code for that?

Regards,
Murthy





Murthy

Thanks, Ron.

Do you think Worksheet_Change event will work for me?

But how will I specify in the code that this Worksheet_Change event should
be triggered only when the value in cell A1 changes?

In other words, the filter should not be attempted by the code when the
cells (other than A1) change.

Regards,
Murthy




"Ron de Bruin" wrote in message
...
Hi Murthy

You can use the change event to run your sub.
http://www.cpearson.com/excel/events.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Murthy" wrote in message

...
I want to filter the data on a sheet, basing on the value in a particular
cell - say A1.

What I have done so far is:
1) I have generated code to filter the list
2) I have provided a pick list in Cell A1
3) I have created a command button, clicking on which will execute the

code
I mentioned in step (1) above.

Instead of clicking on the command button each time, is there a way to
filter the list, as soon as the value in Cell A1 is changed? Which

event
should I use in my code for that?

Regards,
Murthy







Ron de Bruin

Hi Murthy

Use this

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
YourMacroName
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Murthy" wrote in message ...
Thanks, Ron.

Do you think Worksheet_Change event will work for me?

But how will I specify in the code that this Worksheet_Change event should
be triggered only when the value in cell A1 changes?

In other words, the filter should not be attempted by the code when the
cells (other than A1) change.

Regards,
Murthy




"Ron de Bruin" wrote in message
...
Hi Murthy

You can use the change event to run your sub.
http://www.cpearson.com/excel/events.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Murthy" wrote in message

...
I want to filter the data on a sheet, basing on the value in a particular
cell - say A1.

What I have done so far is:
1) I have generated code to filter the list
2) I have provided a pick list in Cell A1
3) I have created a command button, clicking on which will execute the

code
I mentioned in step (1) above.

Instead of clicking on the command button each time, is there a way to
filter the list, as soon as the value in Cell A1 is changed? Which

event
should I use in my code for that?

Regards,
Murthy









Murthy

Ron,

Many thanks ..
I will try this code.

Regards,
Murthy


"Ron de Bruin" wrote in message
...
Hi Murthy

Use this

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
YourMacroName
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Murthy" wrote in message

...
Thanks, Ron.

Do you think Worksheet_Change event will work for me?

But how will I specify in the code that this Worksheet_Change event

should
be triggered only when the value in cell A1 changes?

In other words, the filter should not be attempted by the code when the
cells (other than A1) change.

Regards,
Murthy




"Ron de Bruin" wrote in message
...
Hi Murthy

You can use the change event to run your sub.
http://www.cpearson.com/excel/events.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Murthy" wrote in message

...
I want to filter the data on a sheet, basing on the value in a

particular
cell - say A1.

What I have done so far is:
1) I have generated code to filter the list
2) I have provided a pick list in Cell A1
3) I have created a command button, clicking on which will execute

the
code
I mentioned in step (1) above.

Instead of clicking on the command button each time, is there a way

to
filter the list, as soon as the value in Cell A1 is changed? Which

event
should I use in my code for that?

Regards,
Murthy












All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com