Dear Veenu,

Find attached the required macro.

Copy and paste following code in your MVB Editor.
----------------------------------------------------------------------------------------------------------------------------------------------
'#### Macro for Auto filtering the contents of a workbook based on two
criteria viz sheet name and col.####

Option Explicit



Sub AutoFilterTweak()

Dim rngFilterRange As Range
Dim sCountryName As String
Dim sPeriod As String
Dim wksCountry As Worksheet



Sheets("Main").Select

sCountryName = ActiveSheet.Range("a1").Value

sPeriod = ActiveSheet.Range("b1").Value

MsgBox sCountryName

MsgBox sPeriod

Sheets(sCountryName).Select



ActiveSheet.AutoFilterMode = False

Range("a:y").AutoFilter field:=15, Criteria1:=sPeriod



End Sub

----------------------------------------------------------------------------------------------------------

Please correct the name of India and Monthly in your sheet , Spelling
in Main sheet should be same as in the attached sheet for the macro to
work,.

Also save the macro enabled file in either xlsm or xls(2003 compatible
format).Macro cannt be saved in xlsx file.


In case of any query please revert back.



Regards

Jagjeet Singh

On Jun 22, 12:11 pm, Vinu <[email protected]> wrote:
> Hello Friends,
>
> Need VB code to perform the below process.
>
> Ideally my workbook contains many sheets.  I listed all sheet names (in A1
> cell) in the first page by using datavalidation.  In B1 cell I used the data
> validation for the condition like weekly, yearly and monthly - each sheet in
> column O having weekly , yearly and monthly data.
>
> Needa macro which should select the sheet based on A1 cell and filter the
> data based on B1cellcondition(which ll filter data of O column)and select
> the visible cells only and copy n move the same to new excel file and save
> it in C drive Report folder by giving the sheet name as file name.
>
> Original file should not make any changes.
>
> Could you please help me out.  I attached the file below.
>
> --
> Vinu.
>
>  prob-macro.xlsx
> 24KViewDownload

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to [email protected]

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 7000 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to