Vba if loop help please

kino4city

New Member
Joined
May 17, 2011
Messages
11
Hi all,
I am useless on vba and excel but together OMG!!!.

Well, I want it to search my range(E12:E39), and find out if it contains "APPLE", then if so i need it to insert chart, name "APPLE CHART", in cell b2, size(Height,460pix/Length,720pix), but if cell b2 is active then 2 rows lower...

If you can help that would be great, if you need more details just let me know.

Thanks in advance,
Chris
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi,

what sort of chart are you after + where is the data to go in the chart?

Thanks

Just a basic bar chart, and it based on a different sheet called APPLE GREEN,
but i just want it to show a view only copy in new worksheet in the cell b2 and then...

the loop needs to go round the range an identify which what info is there, i have used APPLE as an example,but for intanse if i have APPLE entered twice i don't want it to show to Charts for APPLE if that makes sense or even helps??
 
Upvote 0
Try this I think this is just about what you are after? note I have selected data from Sheet1 G10:G20 so change as you need.

Code:
Sub Applechart()

    Dim r, f As Range
    Set r = Range("E12", "E39")
    Set f = r.Find(What:="Apple", LookIn:=xlValues, LookAt:=xlPart)

        If Not (f Is Nothing) Then
        ActiveSheet.Shapes.AddChart.Select
        ActiveChart.SetSourceData Source:=Range("'Sheet1'!$G$10:$G$20")
        ActiveChart.ChartType = xlColumnClustered
        Selection.Width = 720
        Selection.Height = 460
        Selection.Left = 49
        Selection.Top = 13
        ActiveChart.SetElement (msoElementChartTitleAboveChart)
        ActiveChart.ChartTitle.Text = "APPLE CHART"

    Else
    MsgBox ("No Apple")
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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