|
こんにちは。
下記を実行するとFor i = 5 To ws1.Range("B5").End(xlDown).Rowのところでオーバーフローしました、と出ます。
何がいけないのか教えていただけませんでしょうか。
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Pnm As String
Dim Cnm As String
Dim ws1 As Worksheet
Dim i As Integer
If Not Application.Intersect(Range("B5:B107"), Target) Is Nothing Then
With Target
Pnm = .Offset(, 1).Value
Cnm = .Offset(, 2).Value
End With
Set ws1 = Worksheets("Sheet2")
For i = 5 To ws1.Range("B5").End(xlDown).Row
If IsEmpty(ws1.Cells(i, 2).Value) Then
ws1.Cells(i, 2).Value = Pnm
ws1.Cells(i, 3).Value = Cnm
End If
Next
Cancel = True
End If
End Sub
|
|