ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection based on values in a cell (https://www.excelbanter.com/excel-programming/275956-selection-based-values-cell.html)

Stewart[_2_]

Selection based on values in a cell
 
Cell A1 contains an integer value
Cell B1 contains a (larger) integer value
The cursor is placed at cell C1
Can anyone tell me what the code would be to select a
range in row 1 which starts at the column value in A1 and
ends at the column value in B1 and then returns the cursor
to C1?
Help would be much appreciated.

Tom Ogilvy

Selection based on values in a cell
 
Sub Tester1()
Range(Rows(Range("A1")), Rows(Range("B1"))).Select
Selection.Interior.ColorIndex = 4
Range("C1").Select
End Sub

Not sure what the point of selecting the rows if if you then move the
selection back to C1.

To maintain the selection and still have the cursor in C1, both
Sub Tester2()
Union(Range(Rows(Range("A1")), _
Rows(Range("B1"))), Range("C1")).Select
Range("C1").Activate
End Sub

--
Regards,
Tom Ogilvy


"Stewart" wrote in message
...
Cell A1 contains an integer value
Cell B1 contains a (larger) integer value
The cursor is placed at cell C1
Can anyone tell me what the code would be to select a
range in row 1 which starts at the column value in A1 and
ends at the column value in B1 and then returns the cursor
to C1?
Help would be much appreciated.





All times are GMT +1. The time now is 02:50 PM.

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