ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Select A Cell in VBA with a Variable Row Number? (https://www.excelbanter.com/excel-programming/445588-how-select-cell-vba-variable-row-number.html)

[email protected]

How to Select A Cell in VBA with a Variable Row Number?
 
Here are examples of normal VBA that works with no variables:

Range("K20").Select
Range("K20").Activate

I want to replace row 20 with a variable from a named cell.

For example, I named cell Z100 as "XRow". XRow now contains the number 7, which can change anytime according to formula. I want the formula to say something like the following, but I can't get it to work:

Range("KXrow").Select
Range("K"Xrow"").Select
Range(Cells(K,Xrow)).Select
Range(Cells(K,"Xrow")).Select

If necessary, I could make do with an unnamed cell, so that it could look something like

Range("KZ100").Select
Range("K"Z100"").Select
Range(Cells(K,Z100)).Select
Range(Cells(K,"Z100")).Select


Any ideas? Thanks!


All times are GMT +1. The time now is 09:44 PM.

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