Generate Graph Based On Set of Data Using VBA

taykaisheng

New Member
Joined
Jul 30, 2013
Messages
10
Hi, i'm very new in VBA.. Currently I'm on my project which required me to creating a automation tool by plotting 2 bar chart automatically based on 2 table data as shown below
However as the table data was generated out from another automation tool thus the number of rows can be increase or decrease. And the problem was due to the number of rows could be more/less than 5, I couldn't select the cells by specifying the address of the cell such as "A7" or "B6".
teamg2fmv


And these are the expected output of the chart
btryd43md

Hope some kind soul could help me on this..
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I can't see your images, but if you want to select from A1 to the last nonempty cell in column A you could use:

Code:
Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Select

You may also find that this works for you:

Code:
Range("A1").CurrentRegion.Select
 
Upvote 0
Thanks for your help.. However now I facing another issue. I want to create a graph based on the table data which I specified using .CurrentRegion with last row of the table data should not be included. Hope you can tell me how to do this, thank you in advance
 
Upvote 0
Example:

Code:
Sub Test()
    Dim Rng As Range
    With Range("A1").CurrentRegion
        Set Rng = .Resize(.Rows.Count - 1)
    End With
    MsgBox Rng.Address
End Sub
 
Upvote 0
Thank you for your quick response, do appreciate that a lot.. However I am facing another issue again. Let's say my CurrentRegion property consists of 3 columns A, B and C but I want to select entire column A and C as my data source for my chart, am I able to do so ? I know i can select column A and B as data source by implementing .Resize(CR.Columns.Count - 1). Thank you in advance
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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