Hello how do I manage to program a Macro to run after a entry on a specific
cell rather than with a key or a button?
thanks!
Hello how do I manage to program a Macro to run after a entry on a specific
cell rather than with a key or a button?
thanks!
Ed wrote:
> Hello how do I manage to program a Macro to run after a entry on a
> specific cell rather than with a key or a button?
>
> thanks!
use a worksheet_change event
Ed, something like this, put in worksheet code
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Address = "$A$1" Then
MsgBox "Test"
End If
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
"Ed" <Ed@discussions.microsoft.com> wrote in message
news:24918902-91A4-4E95-A457-5040CABEE515@microsoft.com...
> Hello how do I manage to program a Macro to run after a entry on a
specific
> cell rather than with a key or a button?
>
> thanks!
Hello Paul, I'm not so familiarized with editing Macros and I have been
trying but I haven't been able to manage it yet... the macro I have recorded
is:
Sub FiltroInvMateriales()
'
' FiltroInvMateriales Macro
' Macro recorded 27/05/2006 by Arquitectura Integral
'
' Keyboard Shortcut: Ctrl+m
'
Selection.AutoFilter Field:=1, Criteria1:="x"
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
End Sub
What is does is just to Filter Column A that has "Autofilter" to show only
the ones that have a "x" on it and then hide Column A. The "x" is given with
a IF formula, so on rows where there are entires it gives and x, those
entries are gathered through VLOOKUP's, and the target of those VLOOKUP's is
a number I select from a dropdown list. The cell where I select that number
is $C$1. What I do so far is to select the number from $C$1 dropdown and then
hit Ctrl+m to run the macro, but I would like to run it automatically each
time I select a number from $C$1.
Where do I have to insert the macro written above into the one you gave me?
thanks a lot!
Ed, see if this will do what you want
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Address = "$C$1" Then
'**no need to select the column to hide it**
Selection.AutoFilter Field:=1, Criteria1:="x"
Columns("A:A").EntireColumn.Hidden = True
End If
End Sub
To put in this macro right click on the worksheet tab and view code, in the
window that opens paste this code, press Alt and Q to close this window and
go back to your workbook. If you are using excel 2000 or newer you may have
to change the macro security settings to get the macro to run. To change the
security settings go to tools, macro, security, security level and set it to
medium
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
"Ed" <Ed@discussions.microsoft.com> wrote in message
news:9052A886-054E-42DB-8EE7-754B174D7D00@microsoft.com...
> Hello Paul, I'm not so familiarized with editing Macros and I have been
> trying but I haven't been able to manage it yet... the macro I have
recorded
> is:
>
> Sub FiltroInvMateriales()
> '
> ' FiltroInvMateriales Macro
> ' Macro recorded 27/05/2006 by Arquitectura Integral
> '
> ' Keyboard Shortcut: Ctrl+m
> '
> Selection.AutoFilter Field:=1, Criteria1:="x"
> Columns("A:A").Select
> Selection.EntireColumn.Hidden = True
> End Sub
>
> What is does is just to Filter Column A that has "Autofilter" to show only
> the ones that have a "x" on it and then hide Column A. The "x" is given
with
> a IF formula, so on rows where there are entires it gives and x, those
> entries are gathered through VLOOKUP's, and the target of those VLOOKUP's
is
> a number I select from a dropdown list. The cell where I select that
number
> is $C$1. What I do so far is to select the number from $C$1 dropdown and
then
> hit Ctrl+m to run the macro, but I would like to run it automatically each
> time I select a number from $C$1.
>
> Where do I have to insert the macro written above into the one you gave
me?
>
> thanks a lot!
Hello Paul, thank you very much! it is exactly what I was looking for, it's
very helpful...
Your welcome, thanks for the feedback
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
"Ed" <Ed@discussions.microsoft.com> wrote in message
news:30B696E4-3403-4737-95A5-D0D46338204C@microsoft.com...
> Hello Paul, thank you very much! it is exactly what I was looking for,
it's
> very helpful...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks