Macro/Method For Removing Headers Associated with Blank Cells From Column Graphs

%3CLINGO-SUB%20id%3D%22lingo-sub-2538253%22%20slang%3D%22en-US%22%3EMacro%2FMethod%20For%20Removing%20Headers%20Associated%20with%20Blank%20Cells%20From%20Column%20Graphs%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2538253%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20Morning%20Forums%2C%3CBR%20%2F%3E%3CBR%20%2F%3EFirst%20post%20here%2C%20so%20hopefully%20the%20community%20can%20help%20me%20out!%20I%20am%20trying%20to%20generate%20a%20column%20graph%20that%20doesn't%20have%20gaps%20in%20it%20when%20data%20is%20not%20present.%20I%20assume%20I%20may%20need%20to%20use%20macros%2C%20so%20I%20need%20some%20assistance%20as%20I%20have%20only%20just%20started%20learning%20VBA.%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20this%20column%20graph%2C%20I%20have%20a%20%22Sample%20Number%22%20for%20each%20row%2C%20and%20within%20each%26nbsp%3B%3CEM%3Esample%3C%2FEM%3E%20there%20could%20be%20a%20number%20of%20substances%20from%200%20(none)%20to%2030%20(substance%20IDs%201-30%20represent%20each%20of%20the%20columns%20for%20any%20given%20sample%2Frow).%20Since%20any%20one%20sample%20could%20have%20any%20number%20of%20the%2030%2B%20substances%2C%20I%20am%20trying%20to%20generate%20a%20graph%20that%20only%20shows%20those%20substances%20which%20are%20present%3B%20essentially%20I%20am%20trying%20to%20create%20a%20%22positive%20only%22%20column%20graph.%3CBR%20%2F%3E%3CBR%20%2F%3ENow%2C%20I%20could%20go%20in%20and%20delete%20each%20substance%20name%20manually%2C%20but%20the%20issue%20is%20the%20highlighted%20cells%20for%20that%20graph%20are%20still%20there.%20So%2C%20even%20if%20I%20delete%20the%20headers%20(substance%20name)%20for%20each%20sample%2C%20then%20what%20I'm%20left%20with%20is%20a%20gap%20in%20the%20column%20graph.%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20what%20I%20am%20thinking%20is%20I%20need%20a%20way%20for%20this%20macro%20(or%20if%20anyone%20has%20some%20other%20ideas)%20that%20will%20check%20to%20see%20if%20a%20sample%20is%20less%20than%20a%20certain%20cutoff%2C%20and%20if%20it%20is%2C%20not%20show%20up%20as%20a%20zero%2C%20or%20a%20gap.%20This%20may%20require%20that%20the%20sample%20headers%20row%20be%20completely%20deleted%20in%20order%20for%20the%20cell%20to%20not%20show%20(I%20really%20am%20not%20sure%2C%20which%20is%20why%20I%20am%20here.)%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20other%20glaring%20issue%20is%20that%20multiple%20samples%20are%20associated%20with%20each%20substance%20name%2C%20and%20therefore%20deleting%20the%20row%20for%20one%20sample%20(with%20not%20data)%20could%20cause%20deletion%20of%20the%20data%20in%20a%20row%20for%20a%20sample%20where%20that%20substance%20is%20present.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20example%2C%20let's%20say%20I%20have%203%20samples%2C%20and%20within%20each%20of%20these%20samples%20there%20are%202%20substances.%20The%20substances%20in%20sample%201%20are%20A%20and%20B%3B%20sample%202%20are%20A%20and%20C%3B%20sample%203%20are%20B%20and%20C.%20That%20means%20that%20in%20samples%201-3%2C%20there%20are%20no%20traces%20of%20D-Z%20etc.%20(since%20I%20have%2030%20substances)%20so%20I%20would%20want%20the%20D-Zs'%20names%20to%20not%20show%20up%20in%20the%20graph.%20Additionally%2C%20the%20problem%20I%20mentioned%20before%3A%20Sample%201%20has%20A%2C%20but%20sample%203%20does%20not...%20I%20can't%20delete%20the%20header%20associated%20with%20both%20of%20these%20then%20(I%20have%20attached%20an%20image%20to%20help).%3CBR%20%2F%3E%3CBR%20%2F%3EI%20know%20this%20is%20probably%20pretty%20complicated%2C%20so%20please%20don't%20hesitate%20to%20ask%20for%20clarifications.%20Maybe%20I%20ought%20to%20learn%20python%20or%20something%20(haaha).%20If%20there%20is%20a%20way%20to%20create%20a%20macro%20for%20it%2C%20that%20would%20definitely%20increase%20the%20efficiency%20of%20this%20whole%20process.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2538253%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECharting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Good Morning Forums,

First post here, so hopefully the community can help me out! I am trying to generate a column graph that doesn't have gaps in it when data is not present. I assume I may need to use macros, so I need some assistance as I have only just started learning VBA.

For this column graph, I have a "Sample Number" for each row, and within each sample there could be a number of substances from 0 (none) to 30 (substance IDs 1-30 represent each of the columns for any given sample/row). Since any one sample could have any number of the 30+ substances, I am trying to generate a graph that only shows those substances which are present; essentially I am trying to create a "positive only" column graph.

Now, I could go in and delete each substance name manually, but the issue is the highlighted cells for that graph are still there. So, even if I delete the headers (substance name) for each sample, then what I'm left with is a gap in the column graph.

So what I am thinking is I need a way for this macro (or if anyone has some other ideas) that will check to see if a sample is less than a certain cutoff, and if it is, not show up as a zero, or a gap. This may require that the sample headers row be completely deleted in order for the cell to not show (I really am not sure, which is why I am here.)

The other glaring issue is that multiple samples are associated with each substance name, and therefore deleting the row for one sample (with not data) could cause deletion of the data in a row for a sample where that substance is present. 

For example, let's say I have 3 samples, and within each of these samples there are 2 substances. The substances in sample 1 are A and B; sample 2 are A and C; sample 3 are B and C. That means that in samples 1-3, there are no traces of D-Z etc. (since I have 30 substances) so I would want the D-Zs' names to not show up in the graph. Additionally, the problem I mentioned before: Sample 1 has A, but sample 3 does not... I can't delete the header associated with both of these then (I have attached an image to help).

I know this is probably pretty complicated, so please don't hesitate to ask for clarifications. Maybe I ought to learn python or something (haaha). If there is a way to create a macro for it, that would definitely increase the efficiency of this whole process.

0 Replies