ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to define a range using variables (https://www.excelbanter.com/excel-programming/392181-how-define-range-using-variables.html)

Givnik

How to define a range using variables
 
How do I assign a range dynamically ie using a string variable, basically I
have a sheet that varies in the number of rows and I do a for next loop but
as yet have not worked out the syntax for how to use a variable in the Range
command... Range("x2:x10").Cells
Code so far

For Each cell In Range("x2:x10").Cells
If cell.PrefixCharacter = "'" Then
cell.Value = cell.Value
End If
Next cell

is it posisble to have something like:
strRange = "X2:X189"
For Each cell In Range(strRange).Cells



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

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