0
チャートを作成しようとしていますが、毎月変更されるので、範囲を選択するようにポップアップボックスが要求されています。範囲をメッセージボックスとして使用するVBAチャート
以下のコードでは範囲を尋ねていますが、グラフは作成されません。
Sub test()
'Set up the variables.
Dim rng As Range
'Use the InputBox dialog to set the range for MyFunction
Set rng = Application.InputBox("Range:", Type:=8)
'Call MyFunction
ActiveCell.Value = MyFunction(rng)
End Sub
Function MyFunction(rng As Range) As Double
MyFunction = ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=rng
End Function
最初の出口のサブMyfunction
を呼び出してからtest
を防止した すべてのヘルプは
Sub test()
'Set up the variables.
Dim rng As Range
'Use the InputBox dialog to set the range for MyFunction
Set rng = Application.InputBox("Range:", Type:=8)
Exit Sub
'Call MyFunction
ActiveCell.Value = MyFunction(rng)
End Sub
Function MyFunction(rng As Range) As Double
MyFunction = ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=rng
End Sub
End Function
ありがとう、それは働いた:) – user3018495