daniel.aquere
New Member
- Joined
- Jun 25, 2012
- Messages
- 5
Hi everyone,
I´m having a strange problem...
When I applied a filter like this:
Dim termino As Date
Dim termino2 As Date
termino = Range("S2").Value
termino2 = DateAdd("d", 7, Range("S2").Value)
Sheets("Expansao - Cronograma GP").Select
ActiveSheet.Range("F3:H100").AutoFilter Field:=1, Criteria1:=">" & Format(termino, "mm/dd/yyyy"), Operator:=xlAnd, Criteria2:="<=" & Format(termino2, "mm/dd/yyyy")
Then I copy and past the result:
Sheets("Expansao - Cronograma GP").Select
Range("F4:H100").Select
Selection.Copy
Sheets("Painel Regina Expansao v1").Select
Range("AI10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
This works fine when the filter return some line, if the filter don´t return any row, my copy/paste copy ALL rows in the source sheet. The correct is don´t copy any row!
Sample available in: http://www.pmpartner.com.br/VBA filter - copy-paste - sample.xlsm
(Module 7 - Sub "e_Filtrar_Painel_Regina_03_Inicio_Proxima_Semana_01_LEVANTAMENTO", called by button "APPLY FILTER" on AI column from "Painel Regina Expansao v1" sheet)
I appreciate any tips.
Best
Daniel
I´m having a strange problem...
When I applied a filter like this:
Dim termino As Date
Dim termino2 As Date
termino = Range("S2").Value
termino2 = DateAdd("d", 7, Range("S2").Value)
Sheets("Expansao - Cronograma GP").Select
ActiveSheet.Range("F3:H100").AutoFilter Field:=1, Criteria1:=">" & Format(termino, "mm/dd/yyyy"), Operator:=xlAnd, Criteria2:="<=" & Format(termino2, "mm/dd/yyyy")
Then I copy and past the result:
Sheets("Expansao - Cronograma GP").Select
Range("F4:H100").Select
Selection.Copy
Sheets("Painel Regina Expansao v1").Select
Range("AI10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
This works fine when the filter return some line, if the filter don´t return any row, my copy/paste copy ALL rows in the source sheet. The correct is don´t copy any row!
Sample available in: http://www.pmpartner.com.br/VBA filter - copy-paste - sample.xlsm
(Module 7 - Sub "e_Filtrar_Painel_Regina_03_Inicio_Proxima_Semana_01_LEVANTAMENTO", called by button "APPLY FILTER" on AI column from "Painel Regina Expansao v1" sheet)
I appreciate any tips.
Best
Daniel