#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15
Default macro Lookup

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?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default macro Lookup

Hard to tell without seeing any code.

--
__________________________________
HTH

Bob

"DamienO" wrote in message
...
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?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default macro Lookup

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

--
Gary''s Student - gsnu200908


"DamienO" wrote:

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?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15
Default macro Lookup

HI,
That works for me after a little change on the sheet.
Thanks for the help

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200908


"DamienO" wrote:

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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Lookup only once - Macro RachuChavan Excel Discussion (Misc queries) 1 June 12th 09 09:53 AM
lookup macro BMI Excel Discussion (Misc queries) 0 February 18th 08 03:10 PM
Lookup macro gramps Excel Discussion (Misc queries) 3 September 14th 07 04:36 PM
lookup macro?? darkbearpooh1 Excel Worksheet Functions 9 February 22nd 06 05:56 AM
Macro lookup dudemango Excel Discussion (Misc queries) 6 February 6th 06 09:20 PM


All times are GMT +1. The time now is 07:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"