If Statement

Matt

Board Regular
Joined
Feb 16, 2002
Messages
212
I'm sure this must have been asked before but I've done a quick search of the forum and couldn't find what I wanted. I need the code for finding out if cell A1 contains a "Y" and if it does then insert a chart. I have the code for inserting a chart but not too sure on the code for checking if "A1" contains "Y" and if it does how to link it to the add chart code. Hope this makes sense and someone can help.

thanks

Matt
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
can't help with code, but is this any help? =IF(ISERROR(SEARCH("y",A1)),FALSE,TRUE) will return TRUE if there's a y in the target cell and FALSE if there isn't.
 
Upvote 0
Hi Matt

You could try something like this:

If Range("A1").Value = "Y" Then Application.Run "name of your chart macro"
End Sub

(this is case sensitive)

hope this helps
regards
Derek
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,617
Members
449,039
Latest member
Mbone Mathonsi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top