ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statement and Macros (https://www.excelbanter.com/excel-programming/312480-if-statement-macros.html)

No Name

If statement and Macros
 
Hi there,

I would appreciate some help woth the following: I want
to run a macro that allows a "clip" to appear if a cell
in Excel gets a certain value. I thought of using an If
statement, but don't seem to get the if statement to
accept a macro. Any help?

Thanks

Andre

Bob Phillips[_6_]

If statement and Macros
 
Andre,

You can't do that, Excel does not allow it.

You could use VBA event code to trap a change and then run your macro,
something like


Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
'do something
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Change the A1 to whichever cell (or cells) that apply.

--

HTH

RP

wrote in message
...
Hi there,

I would appreciate some help woth the following: I want
to run a macro that allows a "clip" to appear if a cell
in Excel gets a certain value. I thought of using an If
statement, but don't seem to get the if statement to
accept a macro. Any help?

Thanks

Andre




Rob van Gelder[_4_]

If statement and Macros
 
You could use an IF statement and format the cell with a font like
Wingdings.

Not sure if there is a clip looking character though.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


wrote in message
...
Hi there,

I would appreciate some help woth the following: I want
to run a macro that allows a "clip" to appear if a cell
in Excel gets a certain value. I thought of using an If
statement, but don't seem to get the if statement to
accept a macro. Any help?

Thanks

Andre




No Name

If statement and Macros
 
Bob,

Thanks for the effort in replying. I'm afraid my Excel
skills do not allow me to fully grasp this. I added the
routine to the sheet code as you said, but still cant get
it to work :( Could I mail you the sheet and you put it
it for me?? I know I'm really pushing it now, but hoped
you would be so kind :)

Regards

Andre
-----Original Message-----
Andre,

You can't do that, Excel does not allow it.

You could use VBA event code to trap a change and then

run your macro,
something like


Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing

Then
With Target
'do something
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs

to be
'placed in the appropriate worksheet code module, not a

standard
'code module. To do this, right-click on the sheet tab,

select
'the View Code option from the menu, and paste the code

in.

Change the A1 to whichever cell (or cells) that apply.

--

HTH

RP

wrote in message
...
Hi there,

I would appreciate some help woth the following: I

want
to run a macro that allows a "clip" to appear if a cell
in Excel gets a certain value. I thought of using an

If
statement, but don't seem to get the if statement to
accept a macro. Any help?

Thanks

Andre



.


No Name

If statement and Macros
 
Thanks Rob,

That is where I am now, but there are only 3 face icons
in my Wingding dictionary. I need 5 (0-20, 21-40, 41-
60,61-80, 81-100). Bob explained in another post how to
really go about it, but, I'm not clued up enough on Excel
to know what he is talking about :( Will have to work at
it a bit more. Thanks for replying.

Andre


-----Original Message-----
You could use an IF statement and format the cell with a

font like
Wingdings.

Not sure if there is a clip looking character though.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


wrote in message
...
Hi there,

I would appreciate some help woth the following: I

want
to run a macro that allows a "clip" to appear if a cell
in Excel gets a certain value. I thought of using an

If
statement, but don't seem to get the if statement to
accept a macro. Any help?

Thanks

Andre



.


Bob Phillips[_6_]

If statement and Macros
 
Sure, send it over

Bob <dot Phillips <at tiscali <dot co <dot uk

I am sure you know how to use it

--

HTH

RP

wrote in message
...
Bob,

Thanks for the effort in replying. I'm afraid my Excel
skills do not allow me to fully grasp this. I added the
routine to the sheet code as you said, but still cant get
it to work :( Could I mail you the sheet and you put it
it for me?? I know I'm really pushing it now, but hoped
you would be so kind :)

Regards

Andre
-----Original Message-----
Andre,

You can't do that, Excel does not allow it.

You could use VBA event code to trap a change and then

run your macro,
something like


Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing

Then
With Target
'do something
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs

to be
'placed in the appropriate worksheet code module, not a

standard
'code module. To do this, right-click on the sheet tab,

select
'the View Code option from the menu, and paste the code

in.

Change the A1 to whichever cell (or cells) that apply.

--

HTH

RP

wrote in message
...
Hi there,

I would appreciate some help woth the following: I

want
to run a macro that allows a "clip" to appear if a cell
in Excel gets a certain value. I thought of using an

If
statement, but don't seem to get the if statement to
accept a macro. Any help?

Thanks

Andre



.





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

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