Donate SIGN UP

Selecting Sells using Excel VBA

Avatar Image
tpreece01 | 19:42 Thu 12th Nov 2009 | Computers
2 Answers
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.
Gravatar

Answers

1 to 2 of 2rss feed

Avatar Image
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...
11: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
Question Author
Thanks for your answer TTG - next time I'll try to spell cell properly! (how embarrassing!)

1 to 2 of 2rss feed

Do you know the answer?

Selecting Sells using Excel VBA

Answer Question >>

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.