VBA这段代码为什么会让数据错行?
问题一:为什么这段代码会让本应该出现在标黄①位置的数据错行到②,而②的数据错行到③,以此类推。Sub调取()Fori=5To125Step8Forj=2To16kk=Sh...
问题一:为什么这段代码会让本应该出现在标黄①位置的数据错行到②,而②的数据错行到③,以此类推。
Sub 调取()
For i = 5 To 125 Step 8
For j = 2 To 16
kk = Sheets(1).Cells(i, 2)
hh = Sheets(2).Cells(j, 1)
If kk = hh Then
kk.Offset(, 1) = Left(hh.Offset(, 1), 2)
kk.Offset(, 2) = Right(hh.Offset(, 1), 2)
kk.Offset(, 6) = Left(hh.Offset(, 2), 2)
kk.Offset(, 7) = Right(hh.Offset(, 2), 2)
→kk.Offset(2⑨ , 6) = Left(hh.Offset(, 3), 2)
→kk.Offset(2⑨ , 7) = Right(hh.Offset(, 3), 2)
……
End If
Next j
Next i
End Sub 展开
Sub 调取()
For i = 5 To 125 Step 8
For j = 2 To 16
kk = Sheets(1).Cells(i, 2)
hh = Sheets(2).Cells(j, 1)
If kk = hh Then
kk.Offset(, 1) = Left(hh.Offset(, 1), 2)
kk.Offset(, 2) = Right(hh.Offset(, 1), 2)
kk.Offset(, 6) = Left(hh.Offset(, 2), 2)
kk.Offset(, 7) = Right(hh.Offset(, 2), 2)
→kk.Offset(2⑨ , 6) = Left(hh.Offset(, 3), 2)
→kk.Offset(2⑨ , 7) = Right(hh.Offset(, 3), 2)
……
End If
Next j
Next i
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询