Excel autofilter incremental

hroerkr11

New Member
Joined
Nov 1, 2018
Messages
1
Hi,

I hope you can help me to solve an issue with this code, I´m using the following code to export the filtered data to a new workbook .
ie. filter information added on sep 15 2018 and create the document then i have to select sep 16 and execute macro to export the info for that day and so for each day.

Im looking for a way to automatically export the information for day 1 to day 31 of each month automatically.

I tried to use a variable here but did not work:
17Sheets("Sheet1").Range("tabla1").AutoFilter Field:=4, Criteria1:=ActiveSheet.Range(****variable here*****).Value

<tbody>
</tbody>



1Sub Generar_Excel()
2Dim Libro1 As String
3Dim NuevoLibro As String
4Dim MyRange As Range
5Dim limpiartabla As ListObject
6Dim i as variant
7
8
9'Limpiar filtro
10Libro1 = ActiveWorkbook.Name
11If Workbooks(Libro1).Worksheets("Sheet1").FilterMode = True Then
12 Workbooks(Libro1).Worksheets("Sheet1").ShowAllData
13End If
14
15'Filtrar informacion
16Sheets("Sheet1").Range("tabla1").AutoFilter Field:=2, Criteria1:=ActiveSheet.Range("B1").Value
17Sheets("Sheet1").Range("tabla1").AutoFilter Field:=4, Criteria1:=ActiveSheet.Range("B2").Value
18Sheets("Sheet1").Range("tabla1").AutoFilter Field:=3, Criteria1:=ActiveSheet.Range("B3").Value
19
20'Seleccionar valores visibles de tabla
21Set MyRange = Sheets("Sheet1").Range("tabla1[#All]").SpecialCells(xlCellTypeVisible)
22
23'Creación de un nuevo documento
24Workbooks.Add
25NuevoLibro = ActiveWorkbook.Name
26
27'Copiar el rango del libro a exportar
28MyRange.Copy
29
30'Pegar informacion en nuevo documento
31Workbooks(NuevoLibro).Activate
32Sheets(1).Activate
33Range("a1").Select
34Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False
35ActiveWorkbook.SaveAs Filename:="RD2-" & Range("D2").Value & " " & Range("C2").Value & " " & Range("B2").Value & " Incidentes Atendidos en el Día", FileFormat:=xlWorkbookNormal
36ActiveWorkbook.Close
37
38End Sub

<colgroup><col width="80" span="2" style="width:60pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
If you want a variable instead of the cells value then this should do it

Code:
[TABLE="class: cms_table"]
<tbody>[TR]
[TD]Sheets("Sheet1").Range("tabla1").AutoFilter Field:=4, Criteria1:= variablenamehere[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top