ChatterBank0 min ago
Excel Macro Problem
4 Answers
I'm writing an Excel VBA macro anad my mind has gone blank.
I want to select a range. Normally this would be (for example):
Range("A1:D10").Select
What I want to do is to vary the range in accordance with the contents of another cell, E1, (where I have a "count" function).
So I want to select the range A1:D(the contents of E1). So if E1 contains the number 6 I want to select A1:D6.
The sort of thing I used to do every day but have lost the habit. Any help would be appreciated.Ta in advance.
I want to select a range. Normally this would be (for example):
Range("A1:D10").Select
What I want to do is to vary the range in accordance with the contents of another cell, E1, (where I have a "count" function).
So I want to select the range A1:D(the contents of E1). So if E1 contains the number 6 I want to select A1:D6.
The sort of thing I used to do every day but have lost the habit. Any help would be appreciated.Ta in advance.
Answers
Best Answer
No best answer has yet been selected by New Judge. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.Sorted it, AB! :-
ActiveSheet.Range(Cells(1, 1), Cells([e1], 4)).Select
This selects the range A1 to D(contents of cell E1). So if E1 contains '6' the range selected would be A1:D6
The Cell syntax in the brackets is Row, Column (so D3 for example would be 3, 4).
I’d used this in various orms many moons ago but it had completely slipped my mind. Thanks for your help.
ActiveSheet.Range(Cells(1, 1), Cells([e1], 4)).Select
This selects the range A1 to D(contents of cell E1). So if E1 contains '6' the range selected would be A1:D6
The Cell syntax in the brackets is Row, Column (so D3 for example would be 3, 4).
I’d used this in various orms many moons ago but it had completely slipped my mind. Thanks for your help.