ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop in Excell with VBA-code. (https://www.excelbanter.com/excel-programming/349526-loop-excell-vba-code.html)

Gunter Schelfhout

Loop in Excell with VBA-code.
 
I need a loop in VBA-code which:
- inserts a value from 1 to 500 in cell N23979
- reads the value from cell Q23975 and inserts these solutions in cells
B23980 to B24480 so I can compare the solutions.

TIA

JE McGimpsey

Loop in Excell with VBA-code.
 
One way:

Dim i As Long
Dim rArg As Range
Dim rRes As Range
Dim rDest As Range

Set rArg = Range("N23979")
Set rRes = Range("Q23975")
Set rDest = Range("B23979")
For i = 1 To 500
rArg.Value = i
rDest.Offset(i, 0).Value = rRes.Value
Next i

Note that the 500 results will only extend to B24479.


In article ,
Gunter Schelfhout wrote:

I need a loop in VBA-code which:
- inserts a value from 1 to 500 in cell N23979
- reads the value from cell Q23975 and inserts these solutions in cells
B23980 to B24480 so I can compare the solutions.

TIA


Gunter Schelfhout

Loop in Excell with VBA-code.
 
JE McGimpsey wrote:

[snip]

I need a loop in VBA-code which:
- inserts a value from 1 to 500 in cell N23979
- reads the value from cell Q23975 and inserts these solutions in cells
B23980 to B24480 so I can compare the solutions.


It works great, thanks.


All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com