|
ご返答ありがとうございます。
>エラーになるプロシージャ全体と、どの行でエラーになるのかを提示されては。^d^
ではお言葉に甘えて、プロシージャ全体を提示してみます。
Private Sub commandbutton1_click()
Dim Row_No As Integer
Dim Col_No As Integer
Dim RowPos As Integer
Dim i As Integer
Dim m As Integer
Dim chtobj As ChartObject
Row_No = 339
Col_No = 2
Application.ScreenUpdating = False
Do ' 'グラフを作るためのloop--------1.
Do '編集を探すためのloop--------2.
If Cells(Row_No, 1).Value <> "編集" Then
Row_No = Row_No + 1
End If
If Cells(Row_No, 1).Value = "YЁd(・`∀・)b S!!" Then
Application.StatusBar = Cells(RowPos - 4, 1).Value
Application.ScreenUpdating = True
With Application
.StatusBar = "処理が終わりました"
.StatusBar = False
End With
Exit Sub
End If
Loop Until Cells(Row_No, 1).Value = "編集" '--------2.
RowPos = Row_No + 1
Row_No = RowPos + 1
i = 1
Do '行(Row_No)の空白セルを見に行くloop--------3.
If Cells(Row_No, 2) <> "" Then
Row_No = Row_No + 1
i = i + 1
End If
Loop Until Cells(Row_No, Col_No) = "" '--------3.
Row_No = Row_No - 1
i = i - 1
Col_No = 2
m = 1
Do '列(Col_No)の空白セルを見に行くloop--------4.
If Cells(RowPos, Col_No) <> "" Then
Col_No = Col_No + 1
m = m + 1
Else
Exit Do
End If
Loop Until Cells(Row_No, Col_No) = "" '--------4.
If m = 1 Then
m = m
Else
m = m - 1
End If
Col_No = Col_No - 1
Cells(RowPos, 20).Select
ActiveCell.FormulaR1C1 = ""
ActiveCell.FormulaR1C1 = "=INT(RC[-19])"
Selection.AutoFill Destination:=Range(Cells(RowPos, 20), Cells(RowPos + i, 20))
Range(Cells(RowPos, 20), Cells(RowPos + i, 20)).Select
Selection.AutoFill Destination:=Range(Cells(RowPos, 20), Cells(RowPos + i, 20 + m))
Cells(RowPos, 20).ClearContents
'Range(Cells(RowPos, 20), Cells(RowPos + i, 20 + m)).Select
If i = 2 Then 'Charts.Add
Set chtobj = ActiveSheet.ChartObjects.Add(Cells(RowPos, 7).Left, Cells(RowPos, 7).Top, 200, 100)
chtobj.Select
With ActiveChart
.ChartType = xlXYScatterSmooth
.SetSourceData Source:=Sheets("Sheet1").Range(Cells(RowPos, 20), Cells(RowPos + i, 20 + m))
.Location Where:=xlLocationAsObject, Name:="Sheet1"
.HasTitle = True
.ChartTitle.Text = Cells(RowPos - 4, 1).Value
.HasLegend = False
End With
ElseIf i >= 3 Then
Set chtobj = ActiveSheet.ChartObjects.Add(Cells(RowPos, 7).Left, Cells(RowPos, 7).Top, 200, 100)
chtobj.Select
With ActiveChart
.ChartType = xlSurface ’----ここでエラーが出ますミ(ノ;_ _)ノ =3
.SetSourceData Source:=Sheets("Sheet1").Range(Cells(RowPos, 20), Cells(RowPos + i, 20 + m))
.Location Where:=xlLocationAsObject, Name:="Sheet1"
.HasTitle = True
.ChartTitle.Text = Cells(RowPos - 4, 1).Value
.HasLegend = False
End With
End If
Loop '--------1.
End Sub
|
|