Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open XLS add Filter to selected columns

Status
Not open for further replies.

Leosy

Technical User
Apr 13, 2012
49
0
0
PL
Hello.

I need open XLS file and add "filter"/"autofilter" columns.
Could you help me with this ?

Code:
Function OK()

Const ForReading = 1
Const ForWriting = 2

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objFile = bjFSO.objExcel("C:\07-05-2012.xls", ForReading)

Excel.Range("A1:Z23").Autofilter 

Set objFile = objFSO.objExcel("C:\Result.xls", ForWriting)

objFile.Write strNewContents
objFile.Close

Set objFile = Nothing
Set objFSO = Nothing

End Function

but it doesnt work :(

could you help me ?
 
Now it working

Code:
OK

Function OK()
  dim wb

  Set objExcel = CreateObject("Excel.Application")
  set wb = objExcel.Workbooks.Open("C:\BegoExcel\(Bego)-BONDUELLE-Rapport de sauvegarde du 07-05-2012 - Copy.xls")

  wb.worksheets(1).Range("A1:Z23").Autofilter
  wb.save
  wb.close

  set wb = nothing
  Set objExcel = Nothing
End Function

I've defined Function but haven't called it. Called it by putting the OK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top