|
まとめてすっきりさせると、こんなコードになります。(コードはソースコードの意味)
処理の順序を直したり、無駄を省いたりするのが編集です。編集がちゃんと出来る
ようになって、初めて中級へと進めます。頑張ってください。
Dim r As Long
Dim PltR As Range
Dim Mfile As String, mf As String
mf = InputBox("ファイル名を入力してください")
If mf = "" Then Exit Sub
Mfile = Mid(FName, 29, 11)
r = Range("G65536").End(xlUp).Row
With Sheets(Mfile)
Set PltR = Union(.Range("G47:G" & r), .Range("J47:J" & r))
End With
With Charts.Add
.ChartType = xlXYScatter
.SetSourceData Source:=PltR, PlotBy:=xlColumns
.HasTitle = True
.ChartTitle.Characters.Text = mf
.HasLegend = False
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Characters.Text = "potential[V]"
With .MajorGridlines
.ColorIndex = 57
.Weight = xlHairline
.LineStyle = xlDot
End With
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Characters.Text = "current density[mA/g]"
End With
With .PlotArea
With .Border
.ColorIndex = 1
.Weight = xlMedium
.LineStyle = xlContinuous
End With
With .Interior
.ColorIndex = 15
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End With
.Location Where:=xlLocationAsObject, Name:=Mfile
End With
Set PltR = Nothing
|
|