日记首页
|
列表
|
添加日记
|
管理登陆
标题:vba中,输入到指定位置,X,Y定位问题,解决了
<p>vba中,输入到指定位置,X,Y定位问题,解决了,方案1:</p><p>Private Sub CommandButton1_Click()</p><p>Dim i, j, k</p><p> For i = 2 To 30<br> For k = 2 To 30<br> For j = 2 To 33<br>If TextBox1.Value = Cells(i, 1) Then</p><p>If TextBox3.Value = Cells(k, 2) Then<br> If i = k Then<br> If DTPicker1.Value = Cells(1, j) Then<br> </p><p> Cells(k, j) = TextBox2.Value<br> End<br> End If<br> End If<br> End If<br> End If<br> Next<br> Next<br> Next<br> <br>MsgBox ("ok")<br>End Sub</p><p><hr><p></p><p>方案2:</p><p>还可以考虑吧i赋值给k,即从i开始来定义k</p><p>Private Sub CommandButton1_Click()</p><p>Dim i, j, k, l</p><p> For i = 2 To 30<br> For k = 0 To 30<br> <br> For j = 2 To 33<br> <br>If TextBox1.Value = Cells(i, 1) Then<br>l = k + i</p><p>If TextBox3.Value = Cells(l, 2) Then<br> If i = k Then<br> <br> If DTPicker1.Value = Cells(1, j) Then<br> </p><p> Cells(l, j) = TextBox2.Value<br> End<br> End If<br> End If<br> End If<br> End If<br> Next<br> Next<br> Next<br> <br>MsgBox ("ok")<br>End Sub<br></p>