PDA

View Full Version : Little help with Visual Basics



iWiishh
11-26-2011, 05:17 AM
Hi,

I'm making a macro to run a set of data and create a chart and process the things that I'm interested in. But kinda faced some problem

1. Does anyone knows the code in visual basics to change the thickness of the lines in charts. The lines are those that joins the different points of data on the chart. It's a bit big, wanna change the thickness. I used record macro, but all it gives me is that i selected the seriesCollection.

2. So far what I've noticed is that the macro function is "attached" to only the excel file I program it in. Is there a way to make it sort of like a user defined function, such that if i've got another new set of similar data in another excel file, I can just run the whole code, without the need to copy and paste the code from the old excel file in that new excel file.

3. i've got this set of data, which has lots of decimal places, not sure what's the default data type when I didnt assign any. Coz it's like I did a calculation from a different set of data, (smth like whole of column B is column A/35). So how do I change the whole set in column B to 2 decimal places? Or what datatype should i use?


Thanks alot!!

Bob Phillips
11-26-2011, 07:15 AM
With Worksheets("Sheet1").ChartObjects("Chart 1")

With .Chart.SeriesCollection(2).Format.Line

.Visible = msoTrue
.Weight = 2#
End With
End With

Paul_Hossler
11-26-2011, 07:36 AM
2. So far what I've noticed is that the macro function is "attached" to only the excel file I program it in. Is there a way to make it sort of like a user defined function, such that if i've got another new set of similar data in another excel file, I can just run the whole code, without the need to copy and paste the code from the old excel file in that new excel file.

3. i've got this set of data, which has lots of decimal places, not sure what's the default data type when I didnt assign any. Coz it's like I did a calculation from a different set of data, (smth like whole of column B is column A/35). So how do I change the whole set in column B to 2 decimal places? Or what datatype should i use?

2. You could FileSaveAs the workbook containing the macro as an Excel AddIn (.xlma) or put it in XLSTART. If you use the add in, remember there's a difference between ActiveWorkbook and ThisWorkbook. So if you're refrerring to anything in the macro-containing workbook, use Thisworkbook.Worksheets ( ...), etc.

3. You can apply a number format to only display 2 decimals, while retaining full precision for calculations

Paul