ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move down the cells in a column (https://www.excelbanter.com/excel-programming/396868-move-down-cells-column.html)

Steve[_91_]

Move down the cells in a column
 
What is the code to move down the cells in a column one by one?

Thanks!

Steve



Rick Rothstein \(MVP - VB\)

Move down the cells in a column
 
What is the code to move down the cells in a column one by one?

Two different approaches to do the same thing...

Sub TestCode1()
Dim R As Range
For Each R In Range("A1:A20")
' Your code goes here in
' place of the following
R.Value = R.Row
Next
End Sub

Sub TestCode2()
Dim X As Long
For X = 1 To 20
' Your code goes here in
' place of the following
Range("B" & CStr(X)).Value = X
Next
End Sub


Rick

Steve[_91_]

Move down the cells in a column
 
Rick,

Double thanks here and thanks for the code to move through worksheets!

Steve


"Rick Rothstein (MVP - VB)" wrote in
message ...
What is the code to move down the cells in a column one by one?


Two different approaches to do the same thing...

Sub TestCode1()
Dim R As Range
For Each R In Range("A1:A20")
' Your code goes here in
' place of the following
R.Value = R.Row
Next
End Sub

Sub TestCode2()
Dim X As Long
For X = 1 To 20
' Your code goes here in
' place of the following
Range("B" & CStr(X)).Value = X
Next
End Sub


Rick





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

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