Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell References and Looping

I have a Looping question.

I have several rows of data to manipulate.. and want an
easy way to increment a cell range. Can I use a variable
in the Cell range name itself..? For instance, on each
pass I copy the values in A1, B1, C1, etc.. someplace else
and do something then increment to A2, B2, C2 etc...

Can I replace the (row component of the cell reference)
e.g. 1, 2, 3 with an integer variable so that I can write
a simple do while or for next loop?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Cell References and Looping

One way, among many:

Dim i As Long
Dim destRange As Range

Set destRange = Sheets("Sheet2").Range("A1")
For i = 1 To 20
Cells(i, 1).Resize(1, 3).Copy _
Destination:=destRange(i, 1)
Next i

(You can substitute Range("A" & i) for Cells(i, 1) if you want.)

another:

Dim cell As Range
Dim destRange As Range
Set destRange = Sheets("Sheet2").Range("A1")
For Each cell In Range("A1:A20")
cell.Resize(1, 3).Copy destRange
Set destRange = destRange.Offset(1, 0)
Next cell


In article ,
"KPaul" wrote:

I have a Looping question.

I have several rows of data to manipulate.. and want an
easy way to increment a cell range. Can I use a variable
in the Cell range name itself..? For instance, on each
pass I copy the values in A1, B1, C1, etc.. someplace else
and do something then increment to A2, B2, C2 etc...

Can I replace the (row component of the cell reference)
e.g. 1, 2, 3 with an integer variable so that I can write
a simple do while or for next loop?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cell References and Looping

I think somehting like this is what you are looking for:

rownum = 1
do until rownum = 10
Range("A" & rownum) = somevalue
rownum = rownum + 1
loop


-----Original Message-----
I have a Looping question.

I have several rows of data to manipulate.. and want an
easy way to increment a cell range. Can I use a

variable
in the Cell range name itself..? For instance, on each
pass I copy the values in A1, B1, C1, etc.. someplace

else
and do something then increment to A2, B2, C2 etc...

Can I replace the (row component of the cell reference)
e.g. 1, 2, 3 with an integer variable so that I can

write
a simple do while or for next loop?
.

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
convert relative cell references to absolute cell references via amacro? Dave F[_2_] Excel Discussion (Misc queries) 1 May 15th 08 04:43 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Looping in VB with cell ranges Freeman Excel Worksheet Functions 2 January 22nd 06 12:14 PM
Faster Way of looping through cell values Andibevan Excel Discussion (Misc queries) 1 August 12th 05 03:10 PM
syntax for relative cell change and looping BwanaP Excel Programming 1 September 27th 03 03:36 PM


All times are GMT +1. The time now is 01: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"