How Can I Automate Line Color Changes in Excel Graphs Using VBA?

  • Thread starter Thread starter juzbe
  • Start date Start date
  • Tags Tags
    Excel
AI Thread Summary
The discussion revolves around automating the process of changing line colors in Excel graphs based on data values across multiple worksheets using Visual Basic. The user has 500 worksheets, each containing varying rows of data and corresponding line graphs. The challenge lies in identifying which data row is plotted against the top row, as this varies from sheet to sheet. A suggestion is made to reorganize the data into a consistent format across fewer sheets to simplify the process. Additionally, utilizing the macro recorder is recommended to create a reusable macro, although it is noted that the VBA code may still need adjustments for each graph due to the differing row placements.
juzbe
Messages
1
Reaction score
0
I'm fairly new to Visual Basic, so the answer to this might be really simple...

So here's the deal:

I have something like 500 Excel worksheets, that each contain the following:

1. 2-N equally long rows of data
2. A Line graph of one of rows 2-N versus the top row

What I need to do is change the line color in the graph, according to the numerical value of each data point. Needless to say, since there are hundreds of these graphs, I'd like to be able to write a macro that will do this for me.

My problem is, the data row that is plotted against the top row varies from sheet to sheet, which means I don't know which row to look at when deciding the color. Is there any way to obtain this information from the Chart object?

Any help would really be appreciated, I'm starting to think I could've done this manually in the time it's taken me to write the macro :)

Thanks in advance!
 
Technology news on Phys.org
First, assuming all 500 worksheets are in one workbook, you should re-organize your data to minimize the number of sheets. Upon re-organization have the data set-up in a consistent format. Then use the macro recorder to record the macro that you can use over and over again. The problem with using a macro with a graph is that you will have to change the VBA code for each graph since the data is located in different rows for each graph. Hope that helps.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top