I need a macro that will select a range based on a number in a cell. If the number in the cell (in this case the cell is K1) is 200 then I want to select Range A2:D201, if it was 100 then select Range A2:D101.
Thanks for the help!
![]() |
I need a macro that will select a range based on a number in a cell. If the number in the cell (in this case the cell is K1) is 200 then I want to select Range A2:D201, if it was 100 then select Range A2:D101.
Thanks for the help!
Sounds right to me. Try it and see if it works.
The answer that was posted seems to have gotten deleted, can you repost please? Thanks!
Following your question, this does what you ask:
It's possible to have the macro figure out how many cells in column A have data in them, if you wish to automate that, too, so you don't have to put a value in K1:Code:Sub SelectRange()
Dim LR As Long
LR = Range("K1").Value + 1
Range("A2:A" & LR).Select
End Sub
Code:Sub SelectRange()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:A" & LR).Select
End Sub
That bit of code helped me very much. Thanks :-)
All times are GMT -7. The time now is 03:31 AM. |