With ActiveSheet.Shapes.AddChart
.ChartType = xlLineStacked
.SetSourceData Source:=Range( _
"'cwapp5_MemCPU-Date-Mem'!$A:$A,'cwapp5_MemCPU-Date-Mem'!$B:$B")
End With
ChDir "D:\WayneCSV"
ActiveWorkbook.SaveAs Filename:="D:\WayneCSV\" & *YourFileNameHere* &".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
YourFileNameHereを、ファイルを保存する名前に置き換えます。
または、アクティブなワークブックを変更して保存するだけの場合
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.FullName, _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
"D:\WayneCSV" 内のすべての可能なワークブックまたはファイルをループしたい場合はmake it work for all my files?
、Excel シート、ワークブック、または "D: \WayneCSV"
編集:
Dim StrFile As String
StrFile = Dir("D:\WayneCSV\*.CSV") ' Looks up each file with CSV extension
Do While Len(StrFile) > 0 ' While the file name is greater then nothing
Workbooks.Open Filename:= "D:\WayneCSV\" & StrFile ' Open current workbook
ActiveSheet.Shapes.AddChart.Select ' Add a chart
ActiveChart.ChartType = xlLineStacked ' Add a chart type
ActiveChart.SetSourceData Source:=Range("$A1:$B1", Range("$A1:$B1").End(xlDown)) ' Set the source range to be the used cells in A:B on the open worksheet
With ActiveChart.Parent
.Height = .Height*1.5 'Increase Height by 50%
.Width = .Width*1.5 'Increase Width by 50%
End With
'Note the setting of the source will only work while there are no skipped blank if you
'have empty rows in the source data please tell me and i can provide you with another
' way to get the information
ActiveWorkbook.SaveAs Filename:="D:\WayneCSV\" & StrFile & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False ' Save file as excel xlsx with current files name
ActiveWorkbook.Close ' Close when finished before opening next file this can be removed if you'd like to keep all open for review at the end of loop.
StrFile = Dir ' Next File in Dir
Loop
フォルダーとデータがないとテストできないので、うまくいくかどうか教えてください。しかし、それはうまくいくはずです。