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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 02:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com