Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Get value form a cell in a loop

I collect a variable column from a messge box:

st = InputBox("Insert column to start")

and I then want to get the value for a range of cells in this column and
subsequent work on them, all in a loop (where lastrow has been determined
elsewhere)

For irow = 2 to lastrow
v1 = (st & ":" & irow ).value
....................
Next irow

This fails as the range has too many " in it. How do I express a range
when I have the column as st (assume st ="C") and the row as irow (assume
irow=2).

Thanks,
Kanga85

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Get value form a cell in a loop

try this line instead

v1 = Range(st & irow).Value

you don't need the ":" for a single cell

--


Gary


"Kanga 85" wrote in message
...
I collect a variable column from a messge box:

st = InputBox("Insert column to start")

and I then want to get the value for a range of cells in this column and
subsequent work on them, all in a loop (where lastrow has been determined
elsewhere)

For irow = 2 to lastrow
v1 = (st & ":" & irow ).value
....................
Next irow

This fails as the range has too many " in it. How do I express a range
when I have the column as st (assume st ="C") and the row as irow (assume
irow=2).

Thanks,
Kanga85



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Get value form a cell in a loop

Thanks Gary,
Kanga85

"Gary Keramidas" wrote:

try this line instead

v1 = Range(st & irow).Value

you don't need the ":" for a single cell

--


Gary


"Kanga 85" wrote in message
...
I collect a variable column from a messge box:

st = InputBox("Insert column to start")

and I then want to get the value for a range of cells in this column and
subsequent work on them, all in a loop (where lastrow has been determined
elsewhere)

For irow = 2 to lastrow
v1 = (st & ":" & irow ).value
....................
Next irow

This fails as the range has too many " in it. How do I express a range
when I have the column as st (assume st ="C") and the row as irow (assume
irow=2).

Thanks,
Kanga85




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Get value form a cell in a loop

I have now found that:
value1=Cells(Row,Column).value
is the correct syntax. i.e. Row before Column

Kamga85

"Kanga 85" wrote:

I collect a variable column from a messge box:

st = InputBox("Insert column to start")

and I then want to get the value for a range of cells in this column and
subsequent work on them, all in a loop (where lastrow has been determined
elsewhere)

For irow = 2 to lastrow
v1 = (st & ":" & irow ).value
....................
Next irow

This fails as the range has too many " in it. How do I express a range
when I have the column as st (assume st ="C") and the row as irow (assume
irow=2).

Thanks,
Kanga85

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
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
Stopping repetitive loop execution through user form (or other ide Mike Excel Programming 8 August 18th 06 05:54 AM
how to choose random namber form loop? pm[_2_] Excel Programming 4 February 3rd 06 08:10 AM
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? Daniel[_14_] Excel Programming 1 August 29th 04 01:20 PM
loop through form objects Steven K Excel Programming 1 August 23rd 04 07:47 PM


All times are GMT +1. The time now is 03:55 AM.

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"