macro Lookup

  • Thread starter Thread starter DamienO
  • Start date Start date
D

DamienO

Hello,
I've set up a macro to filter a list using a week number. Obviously the week
number changes. When i run the macro I have at the moment it keeps the
original week number e.g. 44, every time it runs. I set it up so that you
should be able to put the week number into cell "f2" and then the macro uses
the value to filter the list by.
What have I done wrong?
 
In VBA, AutoFilter likes strings:

Sub Macro1()
Dim s As String, r As Range
s = Range("F2").Value
Set r = Range("G5:I22")
r.AutoFilter Field:=1, Criteria1:=s
End Sub

where G5 thru I22 contains:

alpha beta gamma
40 6 6
42 7 7
43 8 8
42 9 9
41 10 10
40 11 11
45 12 12
50 13 13
46 14 14
41 15 15
44 16 16
41 17 17
44 18 18
43 19 19
43 20 20
49 21 21
49 22 22
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top