Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
rEN rEN is offline
external usenet poster
 
Posts: 1
Default Looping through a range of cells

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 advanc

Ren
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Looping through a range of cells

Hi Ren

A textbox is not next to any cell, it floats above the spreadsheet on the so
called "drawing layer". So it has no idea what's "next to" because it's
below and it's independent.

Best wishes Harald

"rEN" skrev i melding
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Looping through a range of cells

"rEN" skrev ...

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.


"Harald Staff" wrote ...

A textbox is not next to any cell, it floats above the spreadsheet on the so
called "drawing layer". So it has no idea what's "next to" because it's
below and it's independent.


I'm not sure it's as simple as that because a textbox has a Placement
(Active X controls from the Controls toolbox) or object placement
(Forms toolbar) property e.g. move and size with cells. So it must
have some regard to its position relative to a cell. I'm not sure
whether there is any practical application for the OP in this, though.

Perhaps the OP's needs can be fulfilled by the textbox's LinkedCell
property. If they need subtly different functionality they could,
assuming an ActiveX textbox, write code to make the required link e.g.
a class with 'WithEvents' Textbox and Range properties.

Jamie.

--
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Looping through a range of cells


"Jamie Collins" skrev i melding
om...
A textbox is not next to any cell, it floats above the spreadsheet on

the so
called "drawing layer". So it has no idea what's "next to" because it's
below and it's independent.


I'm not sure it's as simple


You're absolutely right Jamie, my reply is oversimplified. But the layer
stuff is real, and the cell relations you mention is somewhere between
impossible to handle and impossible to get to. If I had a reasonable way to
do this, I'd be glad and proud to provide it. Likewise if someone proves me
wrong -those solutions are always fantastic and worth the pain of posting
"impossible" when it's not :-)

Best wishes Harald


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping thru a range of cells COBOL Dinosaur New Users to Excel 9 June 2nd 07 03:41 AM
looping through a range Jo[_6_] Excel Programming 1 October 21st 03 11:11 PM
Further Help Req'd - Looping thru cells in named range Michael Beckinsale Excel Programming 4 September 2nd 03 08:18 PM
Looping thru cells in a named range Michael Beckinsale Excel Programming 4 September 2nd 03 02:07 PM
looping cells though a named range Jo[_4_] Excel Programming 1 August 20th 03 12:32 AM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"