|
▼ゆうすけ さん:
>Sh2Range.Offset(newRecordOffset, 0).Value = newRecordValues
>で、「型が一致しない」となってしまいます。
たぶん、それより前の段階で間違っていると思います。
>Dim newRecordOffset As Variant
>Set newRecordOffset = Sh2.Range("E24")
Option Explicit
Sub saveData()
Dim i As Long
Dim Sh1 As Worksheet
Dim Sh2 As Worksheet
Dim Sh1Range As Range
Dim Sh2Range As Range
Dim newRecordOffset As Long
Dim dataRow As Long
Set Sh1 = Worksheets("1")
Set Sh1Range = Sh1.Range("K14:K41")
Set Sh2 = Worksheets("2")
Set Sh2Range = Sh2.Range("E24")
For i = 14 To 41
If Worksheets("1").Cells(i, 16).Value = 1 Then
dataRow = 1
newRecordOffset = Sh2Range.Value
Do While Sh1Range.Cells(dataRow, 0).Value <> ""
Sh2Range.Offset(newRecordOffset, 0).Value = _
Sh1Range.Cells(dataRow, 1).Value
dataRow = dataRow + 1
newRecordOffset = newRecordOffset + 1
Loop
End If
Next i
End Sub
|
|