Use conditional statements to add data to scatterplot - vba

I am new to VBA and have not had experience with creating many charts.The chart has to be created by hand because the data has to be visually inspected to see if it meets certain criteria, and not every cell in a column needs to be added to the chart. The chart is to show information for each asset. Not every asset will have information that can be entered on the graph. Is there a way to use VBA to conditionally add data points to a graph?
For example if an asset sees values between 0-30 plot a dot (green) 30-50 (red) etc.

Such a scenario can be achieved with data layout and formulas. No need for VBA, which would need to be re-run, where as formulas will update automatically.
Consider the following screenshot:
The formula in cell C3 is =IF($B3<30,$B3,NA()) and in D3 =IF($B3>=30,$B3,NA()) copied down.

Related

How to zoom chart specific area in Excel Using Macro

Hy Everyone,
I have a sheet with chart that has many values with X-Axis. These values are many in numbers some time I feel difficult to view them, So I want to zoom the any area of the chart by selecting any where in the chart. I used recorded macro that only zoom sheet not Chart / Graph. But I want a macro that can zoom any specific area of the chart or graph any where I click or select..
Here is pictures of the sheets...
My suggestion is to limit the x-axis (minimum and maximum) and probably limit the max value of the y-axis. This way it will only show a part of the data within the chart which might result in a better resolution to view then. But there is no built-in zoom like you described. Therefore you will need to code that on your own.
(Sorry for the german screenshot …)
As you see in the example above. I have total data in x-axis from 0 to 450 and in the second chart I limited the x-axis from 100 to 200. Both charts have the same source data, but the second only shows a part of the first.

Formulas to Switch Row and Column References in Excel

I have raw data that is arranged like this:
The top row is the trial number. Then the first entry in each row is an ID.
I'm trying to set up a template for this data. When this data is pasted in, I want it to be read by another sheet. This sheet will automatically transpose the data, so that it looks like this:
On this sheet, then, I've been trying to write a formula that will increment horizontally when dragged down vertically. When I copy the formula horizontally, I would need it to increase the row reference, not the column reference, so that it'll reproduce the end result in the screenshot above.
I've tried variations on a formula like
INDEX('Asset Returns'!$B$2:$Z$2,COLUMN()-1,ROW()-1)
but I haven't been able to get it working as described. Thanks in advance for any suggestions on what I'm doing wrong.
Not sure if I've understood, but if what you're doing is transposition, but wanting to do it via a common forumla in all the destination cells, you can do it using this:
=INDIRECT(ADDRESS(COLUMN(A1),ROW(A1),1,1,"Asset Returns"))
This should be pasted into the A1 cell of your "transposed" sheet, or adjust the cell reference accordingly if that isn't where the data is.
Another option is:
=OFFSET('Asset Returns'!$A$1,COLUMN(A1)-1,ROW(A1)-1)

Excel Macro to combine cells of data when data matches in another column

The best way I can explain my problem is by showing a few screenshots.
I need to turn data like this:
[
Into something that displays like this:
After Data
There are multiple part numbers in the file, and I need the macro to take all the data from a matching part number and transform the data into what is displayed in the second image. All the part numbers are grouped with their data together, so it wouldn't need to run the loop through the top every single time, but adding to the entries with each new piece of data. Something also needs to be done for the years as well, because the way the data is presented, is in a range of years, and I need an entry for each year in that range.
Additional Information:
I am using this data for prep for category data for a BigCommerce site, that is working with a year/make/model plugin on the site, to create a vehicle lookup system. Thus in order for the user to look up their vehicle accurately the categories need to be listed the way they are in the second picture, which needs to be the result of the macro.
I thank anyone who takes the time to look into this, it will cut down the time I spend doing this manually by a huge amount.
You can do this with a formula (without actual VBA):
In cell F2 write: ="YMM/"&C2&"/"&D2&"/"&E2&";"
In cell F3 write: =F2&"YMM/"&C3&"/"&D3&"/"&E3&";"
drag down the formula in F3 until the last row.
The last row will contain the entire string of all vehicles.
I just noticed you may have duplicate values. You can use the built in Remove Duplicates feature to remove those before using the above technique.

Where is this EXCEL Sheet's data stored?

I am stuck at this problem which involves extracting data from a excel spreadsheet. And the values are "hidden" behind a "interface". I was given a excel file with the coordinate system and for the specified coordinates, when you click on them, a value is displayed to you on the small window above the spreadsheet.
I need all these values and I am sure that I could extract them all at once, not one by one.
So I need to gather all the values that are assigned to the specific coordinates and implement it in my program. Also there is this red-green interface which points out if the value is above a specified number.
But how do I get to the values?
Excel Spreadsheet Link.
They are stored in that row by column. The reason that you cannot see them when you open it is that the size of the column have been reduced. To see the actual number in the row by column, just expand that column by dragging it to the right. For example, in spreadsheet EEM_80_Eini+Ausi, if you look at cell B3 and expand the row and column, you will see the number .2450610558 inside that cell.

bind Data table to chart in vb

I have a project that im working on at the moment in VB.
Basically I have a Data Table in VB it populates with 4 columns and a variable number of rows, the column names are as follows;
Gear, RPM, Speed, CO2
The data table appears in datagridview correctly but that's as far as I have gotten :/
What I am trying to do is to make a line chart called mainGraph to draw a graph based on these results, I'm getting stuck when trying to populate the chart.
ANY thoughts would be really appreciated.
I am guessing you are using the ms chart controls and not some 3rd party like Telerik.
This should be usefull http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx
Also, there is source code found at http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418
in short this is a way to get things displayed
mainGraph.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
mainGraph.Series(0).Points.DataBind(yourDataTable.DefaultView, "Speed", yourDataTable.DefaultView, "Gear")
These commands should make a line graph with Speed on your x axis, and Gear on your Y. Assigned to "Series(0)"
To add more columns, you need to add more "Series"
mainGraph.Series.Add("RPM")
Do some thinking about how you want this data displayed.
how would you like to set this graph up?
I'm assuming you would want a line graph?
What is going to be the X axis? Is there a missing column that needs to be "time" in the data table?
do you want them all on one graph/chart area?
If you would like more charts, then you need to add chart areas. A series can be assigned to a chart area.
Hopefully this helps.