ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using variable as row reference in VBA (https://www.excelbanter.com/excel-programming/378874-using-variable-row-reference-vba.html)

Deecrypt

Using variable as row reference in VBA
 
Hi,
In my macro, I'm trying to reference an integer as a row reference.
The idea is that as the macro goes through the worksheet, the integer
will increment where required. Currently the cell is in column A. Any
help would be greatly appreciated.


Dim CellCount As Integer
Dim OrderCount As Integer

CellCount = 6
OrderCount = 1

Range("A&CellCount&").Select
ActiveCell.FormulaR1C1 = OrderCount

OrderCount++


Thank you kindly
Khurram


Deecrypt

Using variable as row reference in VBA
 
Thank you Randy, This has given me a good point of reference.

regards
Khurram

RST wrote:

Khurram,

I use "cells" when I want to increment through rows or columns in a
worksheet. Try something like this:

Dim CellCount as Integer
Dim OrderCount as Integer

CellCount = 6
OrderCount = 1

Do Until ........[Enter Do/Loop Criteria]

Cells(CellCount,1)=OrderCount

CellCount=CellCount + 1
OrderCount=OrderCount + 1

Loop Until .......[Enter Do/Loop Criteria]

Hope this helps...
Randy




"Deecrypt" wrote:

Hi,
In my macro, I'm trying to reference an integer as a row reference.
The idea is that as the macro goes through the worksheet, the integer
will increment where required. Currently the cell is in column A. Any
help would be greatly appreciated.


Dim CellCount As Integer
Dim OrderCount As Integer

CellCount = 6
OrderCount = 1

Range("A&CellCount&").Select
ActiveCell.FormulaR1C1 = OrderCount

OrderCount++


Thank you kindly
Khurram





All times are GMT +1. The time now is 09:43 AM.

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