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