|
vba中,输入到指定位置,X,Y定位问题,解决了,方案1: Private Sub CommandButton1_Click() Dim i, j, k For i = 2 To 30 For k = 2 To 30 For j = 2 To 33 If TextBox1.Value = Cells(i, 1) Then If TextBox3.Value = Cells(k, 2) Then If i = k Then If DTPicker1.Value = Cells(1, j) Then Cells(k, j) = TextBox2.Value End End If End If End If End If Next Next Next MsgBox ("ok") End Sub
方案2: 还可以考虑吧i赋值给k,即从i开始来定义k Private Sub CommandButton1_Click() Dim i, j, k, l For i = 2 To 30 For k = 0 To 30 For j = 2 To 33 If TextBox1.Value = Cells(i, 1) Then l = k + i If TextBox3.Value = Cells(l, 2) Then If i = k Then If DTPicker1.Value = Cells(1, j) Then Cells(l, j) = TextBox2.Value End End If End If End If End If Next Next Next MsgBox ("ok") End Sub
|