![]() |
|
#1
|
|||
|
|||
![]()
Thanks Whatsup. I am a bit confused with the entering a formula in sheet 2 and putting the code in. Like I said If sheet 1 is not open where the saved macro is (which I recorded), I get error - I am looking for a way to make the macro run regardless of which sheet is open. Your assistance in getting this right will be appreciated. Below is my sample code, kindly modify to make it clearer. Thanks
Sub Trials() ' ' Trials Macro ' ' Selection.AutoFilter ActiveSheet.ListObjects("Table_Query_from_MS_Acces s_Database").Range. _ AutoFilter Field:=6, Criteria1:="Owner" ActiveSheet.ListObjects("Table_Query_from_MS_Acces s_Database").Range. _ AutoFilter Field:=13, Criteria1:="WA" Cells.Select Range("Table_Query_from_MS_Access_Database[[#Headers],[First Name]]").Activate Selection.Copy Sheets("Result").Select Range("A1").Select ActiveSheet.Paste Range("A1").Select End Sub |
#2
|
|||
|
|||
![]()
QueryTables - hm
![]() Anyway, try if this works: Code:
Sub Trials() ' ' Trials Macro ' ' With Sheets(1) .Range("A3").AutoFilter 'replace Range A3 by the first cell you're autofilter starts .ListObjects("Table_Query_from_MS_Acces s_Database").Range. _ AutoFilter Field:=6, Criteria1:="Owner" .ListObjects("Table_Query_from_MS_Acces s_Database").Range. _ AutoFilter Field:=13, Criteria1:="WA" .Range("Table_Query_from_MS_Access_Database[[#Headers],[First Name]]").Copy _ Destination:=Sheets("Result").Range("A1") End With End Sub |
#3
|
||||
|
||||
![]()
Unless, of course, your code activates the sheet concerned (e.g. ThisWorkBook.Sheets("MySheet").Activate). But even that requires the sheet to be named for activation. Not a recommended way to program - it's both inefficient and error-prone.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]()
Thanks Whatsup - your bottom explanation spoke volume. I am just picking up with Macro and programming and thanks for Helping! I just named the sheet and referenced that, which helped.
Macropod - I appreciate your input. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
hanvyj | Excel Programming | 4 | 12-14-2012 03:23 AM |
Make row in one sheet equal column of another | hypertyper | Excel | 6 | 01-31-2012 03:48 PM |
confirmation popup on excel sheet macro | mark-gabb | Excel Programming | 3 | 12-22-2011 01:16 AM |
Debug for macro run through button only when sheet protected | leahca | Excel Programming | 0 | 11-24-2011 04:47 AM |
copy cell from sheet 2 to sheet 3 macro | slipperyjim | Excel Programming | 1 | 02-18-2010 01:31 AM |