LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Autofilter a range in a different instance of excel


Hi All,

This is a follow on problem from my posting earlier, but is a totally
different issue (I think) so I stated a new thread.

Previous thread about exporting range of data to new instance of
excel:

...


I have now done that successfully (thanks guys).

However, my code also attempts to autofilter the exported range for
the convenience of the user (see below).

I have commented where I think the problem area starts and finishes
(between the XXXX lines).

What the code actually does is remove (or add if already removed) the
autofilter in the source workbook application instance, rather than
the
destination (exported) workbook application instance.

Any suggestions?

Thanks,

Alan.


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


Private Sub cmdExportDatabase_Click()


Set newxlApp = New Excel.Application

newxlApp.Visible = True

Set newBook = newxlApp.Workbooks.Add

newBookName = ("Export as at " & Format(CDate(Now()), "HHMM DDDD D
MMM YYYY"))

With newBook

.Title = newBookName
.Subject = "Inventory"
.SaveAs Filename:=newBookName

End With


ThisWorkbook.Worksheets("Database").Activate

Cells.Select

Selection.Copy


newBook.Worksheets("Sheet1").Activate

newBook.Worksheets("Sheet1").Range("A1").PasteSpec ial
(xlPasteValues)

newBook.Worksheets("Sheet1").Cells.Validation.Dele te

' XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

' This is where I think it goes wrong - the autofilter does not get
' applied to the selected range (as I believe I am selecting)


newBook.Worksheets("Sheet1").Activate

newBook.Worksheets("Sheet1").Range("A2").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AutoFilter

' I tried this too:

' Set ExportedRange = newBook.Worksheets("Sheet1").Range("A2")
' Range(ExportedRange, ExportedRange.End(xlToRight)).Select

' But that does not work either - invalid code apparently

' End of problem?

' XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

newBook.Worksheets("Sheet1").Range("A1").Copy
newBook.Worksheets("Sheet1").Range("A1").Select



ThisWorkbook.Worksheets("Active").Activate


MsgBox ("Database exported")


End Sub


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+




 
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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
What is Range For Chart AutoFilter Range VBA? [email protected] Excel Discussion (Misc queries) 0 April 19th 06 05:30 PM
Find 2nd instance of a word in a range. Grumpy Grandpa Excel Worksheet Functions 8 December 5th 05 03:29 PM


All times are GMT +1. The time now is 10:26 AM.

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

About Us

"It's about Microsoft Excel"