Hi, I am new to programming so please bear with me. I have pieced together a code which accomplished what I want it to do (creates bar graphs with a target line). Now I am just trying to simplify the code.
For example, I don't want to activate and select windows...instead I would like to just call worksheets directly. Also, I think the graph definitions can be cleaned, I just don't know how.
Would appreciate any guidance! -
Sub LoudnessChart(Row As String)
-
Dim LChart As ChartObject
-
Dim Lrange As Range
-
Dim Trange As Range
-
Dim Lstr As String
-
Dim Lname As String
-
-
-
Windows("Sorted OSQ HC 031910.xls").Activate
-
Sheets("ARLSummary").Select
-
-
Set Lrange = Range(Cells(Row, 19), Cells(Row, 23))
-
Set Trange = Range(Cells(4, 7), Cells(Row, 7))
-
Lname = "=ARLSummary!R" & Row & "C3"
-
-
Windows("Sorted OSQ HC 031910.xls").Activate
-
Sheets("Temp").Select
-
-
Set LChart = ActiveSheet.ChartObjects.Add _
-
(Left:=100, Width:=375, Top:=75, Height:=225)
-
-
'Define Seriescollection(1)
-
LChart.Chart.SetSourceData Source:=Lrange
-
LChart.Chart.ChartType = xlColumnClustered
-
LChart.Chart.SeriesCollection(1).XValues = "=ARLSummary!R3C19:R4C23"
-
-
LChart.Chart.SeriesCollection(1).Name = Lname
-
With LChart.Chart
-
.HasLegend = False
-
.HasTitle = True
-
.ChartTitle.Characters.Text = Lname
-
.Axes(xlCategory).HasTitle = False
-
.Axes(xlCategory).TickLabelSpacing = 1
-
' .Axes(xlCategory).TickLabels.Orientation = xlUpward
-
.Axes(xlValue).HasTitle = True
-
.Axes(xlValue).AxisTitle.Characters.Text = "Sones"
-
End With
-
-
'Define Seriescollection(2)
-
LChart.Chart.SeriesCollection.Add Source:=Trange
-
With LChart.Chart.SeriesCollection(2)
-
.ChartType = xlXYScatter
-
.XValues = "=(ARLSummary!R4C6,ARLSummary!R172C6)"
-
' .values = cells(4, 7)
-
.Values = "=(ARLSummary!R4C7,ARLSummary!R172C7)"
-
.Name = "Target"
-
.ErrorBar Direction:=xlX, Include:=xlMinusValues, Type:=xlFixedValue, Amount:=1
-
End With
-
-
With LChart.Chart.SeriesCollection(2)
-
.Shadow = False
-
.MarkerStyle = xlNone
-
End With
-
-
With LChart.Chart.SeriesCollection(2).ErrorBars
-
.Border.LineStyle = xlContinuous
-
.Border.ColorIndex = 3
-
.Border.Weight = xlMedium
-
.EndStyle = xlNoCap
-
End With
-
-
With LChart.Chart
-
.HasAxis(xlCategory, xlPrimary) = True
-
.HasAxis(xlCategory, xlSecondary) = True
-
.HasAxis(xlValue, xlPrimary) = True
-
.HasAxis(xlValue, xlSecondary) = False
-
.ApplyDataLabels AutoText:=True
-
.PlotArea.Interior.ColorIndex = xlNone
-
End With
-
-
With LChart.Chart.Axes(xlCategory, xlSecondary)
-
.MinimumScale = 0
-
.MaximumScale = 1
-
.MajorTickMark = xlNone
-
.MinorTickMark = xlNone
-
.TickLabelPosition = xlNone
-
End With
-
-
With LChart.Chart.SeriesCollection(1).DataLabels.Font
-
.Name = "Arial"
-
.FontStyle = "Bold"
-
.Size = 10
-
.ColorIndex = 32
-
End With
-
-
With LChart.Chart.SeriesCollection(2).DataLabels.Font
-
.Name = "Arial"
-
.FontStyle = "Bold"
-
.Size = 10
-
.ColorIndex = 3
-
End With
-
End Sub
-
0 1183 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Marc |
last post by:
Hi all,
I am trying to write an application where I need the ability to open
an Excel spreadsheet and do basic read/write, insert rows, and
hide/unhide rows. Using win32com I have been able to...
|
by: Larry Rekow |
last post by:
I've built various web apps using Frontpage and/or ASP and Access, but
now I'm trying to figure a way to do the following, perhaps in ASP.Net
My friend gets parts lists in invoices (they are in...
|
by: CR |
last post by:
To prepare a PC for my .NET apps I have to run mdac_typ.exe,
dotnetfx.exe, and .NET setup programs for every application. Since I
have around 8 apps this adds up to 10 installs for every pc.
Is...
|
by: Coleen |
last post by:
To export data from a datagrid to an excel file. I am using VB.net/ASP.net
v 2003, and not connecting to an SQL database. I have an existing datagrid
that I want to get the data from and download...
|
by: freeskier |
last post by:
Hello,
I am looking for some advice on collecting data. We are working on collecting about 20 different data points from 60 initial people, later to be expanded to approximately 200. At present we...
|
by: pic078 via AccessMonster.com |
last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files)
that remains stuck in task manager after exiting the application - you can't
reopen database after exiting as a result...
|
by: runsun |
last post by:
Thanks in advance. This program is written in C.
It needs to read all characters from a file; then write them into a 3D array (yes, 3D!).
The file is a .prn file (one of the Excel types), which...
|
by: AmLegacy |
last post by:
I'm having a hard time figuring out how to simplify the fractions. Can anyone look at this code and see if you can see something I don't.
//This is the fraction adding function
void add_fractions...
|
by: hitencontractor |
last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003.
I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About.
The application...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |