Selecting a block of cells depending on the values of two others
Closed
jwilson28
TrowaD
- Posts
- 3
- Registration date
- Friday April 21, 2017
- Status
- Member
- Last seen
- December 5, 2017
TrowaD
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Related:
- Selecting a block of cells depending on the values of two others
- Range of cells depending on a condition. ✓ - Forum - Excel
- Highlight the linked cell depends on drop-down list choice ✓ - Forum - Excel
- Conditional formatting for cells depending on other cells ranges ✓ - Forum - Excel
- Selecting the next empty cell in a row / vba ✓ - Forum - Programming
- Select a subset of cells within a row ✓ - Forum - Excel
3 replies
Try this. Record your Macro, and view it (edit it). Then change the part of the macro you want to have be dynamic. Post back if you have any questions.
OK, that is a start then. Thanks for you posting back!
Initilize a variable, call it a "ARANGE", and set it as a RANGE.
Set ARANGE to "A50:C50"
now, utilize it as RANGE(ARANGE).select
Try that. You can then set ARANGE to what ever variable (range, cell) you wish!
Initilize a variable, call it a "ARANGE", and set it as a RANGE.
Set ARANGE to "A50:C50"
now, utilize it as RANGE(ARANGE).select
Try that. You can then set ARANGE to what ever variable (range, cell) you wish!
TrowaD
Apr 25, 2017 at 12:09 PM
- Posts
- 2886
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- June 27, 2022
Apr 25, 2017 at 12:09 PM
Or try this:
When your active cell is C4 and you add 4 rows you get row 8.
When you add 5 to column C (=3) you will get column H (=8).
So when A50=4 and C50=5 and C4 is active cell, then selected range after macro is run, will be C4 to H8.
Best regards,
Trowa
Sub RunMe() ActiveCell.Resize(Range("A50").Value + 1, Range("C50").Value + 1).Select End Sub
When your active cell is C4 and you add 4 rows you get row 8.
When you add 5 to column C (=3) you will get column H (=8).
So when A50=4 and C50=5 and C4 is active cell, then selected range after macro is run, will be C4 to H8.
Best regards,
Trowa
Apr 22, 2017 at 08:10 AM
I have the code
Sub Select6()
Range(ActiveCell(1, 1), ActiveCell(6, 6)).Select
This code highlights a a block of 6 rows and 6 columns to the right of the active cell
I am struggling to replace the numbers so rather than highlighting the number of cells that are in the code it highlights number of cells from the the values in cells A50 and C50
Jon