Looping through a range of cells
One possible indirect approach would be to use a looping technique to try
and find the cell who's Top, Left, (Top+Height), (Left+Width) values will
contain the Top and (Left+Width) values of the Textbox.
cell.Top textbox.Top cell.Top + cell.Height
cell.Left < textbox.Left + textbox.Width < cell.Left + cell.Width
Kinda ugly, but it seems to work.
Troy
Sub FindTextboxCell()
Dim rngCell As Range
Dim ii As Long
Dim lngCol As Long
Dim lngRow As Long
For ii = 1 To 256
Set rngCell = Sheet1.Cells(1, ii)
If rngCell.Left Sheet1.TextBox1.Left + Sheet1.TextBox1.Width Then
lngCol = rngCell.Column
Exit For
End If
Next ii
For ii = 1 To 65536
Set rngCell = Sheet1.Cells(ii, 1)
If rngCell.Top Sheet1.TextBox1.Top Then
lngRow = rngCell.Row
Exit For
End If
Next ii
Sheet1.Cells(lngRow, lngCol).Select
Sheet1.Cells(lngRow, lngCol).Value = "I found it"
End Sub
"rEN" wrote in message
...
Hi!
I have six TextBox that I'm looping through and at the same time I need to
change the value of the cell next to the TextBox.
How can I do this?
Many thanks in advance
Ren
|