News3 mins ago
Selecting Sells using Excel VBA
I want to return the top x results from a filtered and sorted list.
Currently it's set to the top three with Range("A3:AS7").Select (including the header).
I'd like the user to select how many results are returned by entering the number into the cell (say A1), so it'd look like 'Range("A3:<<A1>>").Select.
Is there an easy way to do this as I can't figure it out? (Without doing an endless list of IF THEN ELSE for 1:x).
Thanks for any help.
Currently it's set to the top three with Range("A3:AS7").Select (including the header).
I'd like the user to select how many results are returned by entering the number into the cell (say A1), so it'd look like 'Range("A3:<<A1>>").Select.
Is there an easy way to do this as I can't figure it out? (Without doing an endless list of IF THEN ELSE for 1:x).
Thanks for any help.
Answers
This macro code might be a start:-
There is a list of 10 values in the first column. Key in a value into B3 and run the macro. Only the first rows up to the value in B3 will be shown. For example, enter 4 into B3 and only the first 4 rows will be shown. Each time you key in a value into B3, you will have to run the macro but I am sure there are ways to automaticall y run the...
10:21 Fri 13th Nov 2009
This macro code might be a start:-
There is a list of 10 values in the first column. Key in a value into B3 and run the macro. Only the first rows up to the value in B3 will be shown. For example, enter 4 into B3 and only the first 4 rows will be shown. Each time you key in a value into B3, you will have to run the macro but I am sure there are ways to automatically run the macro if the value in B3 is changed.
test = Cells(3, 2).Value
Range("A1:A10").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range(Cells(1, 1), Cells(test, 1)), Unique:=False
There is a list of 10 values in the first column. Key in a value into B3 and run the macro. Only the first rows up to the value in B3 will be shown. For example, enter 4 into B3 and only the first 4 rows will be shown. Each time you key in a value into B3, you will have to run the macro but I am sure there are ways to automatically run the macro if the value in B3 is changed.
test = Cells(3, 2).Value
Range("A1:A10").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range(Cells(1, 1), Cells(test, 1)), Unique:=False
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.