Date filter service range in holiday plan

Asked

Viewed 40 times

-1

Good evening friends, I have a scale of service in excel that is daily and I have a camp for departures ( vacation), I need to create a filter where only appear in such field professionals who are on vacation that day according to the date of the scale, as I have to make the scales of sex Sab dom e seg and eventually on extended holidays, several stopovers, this filter needs to select in the tab "vacation" only those who are on vacation, ex if Joseph is on vacation until Sunday he appears in the field itself in the sex scales, Sab and Dom but not from now on. Or if he goes on vacation from Monday the filter just puts him in the field from this day on

I know it has to be via vba but I don’t know much about that part. Office 2010/2016.

Something like, you know, date of scale= L5 Start date= Z4 Final date= Z5

 SELECT * FROM 'ferias' WHERE L5>=Z4 E L5<=Z5

1 answer

-1

'I was able to make it work as follows:

Sub sql() Dim Scale As String Dim Home The String Dim Final As String Dim Pushes Away The String Dim Proximo As String line = 0

Scale = Range("AA1"). Value Distance = Range("AB2"). Value Home = Range("AG2"). Value Final = Range("AH2"). Value 'cellula AA1 equals date of scale 'Retreat is the type of departure (holidays, maternity leave, etc...) 'I start the start date 'Final the final date

Range("AJ:AY").Clear

Do While Afastar <> ""

If Escala >= Inicio And Escala <= Final Then
     Range("AB2" & linha & ":AI2" & linha).Copy
    Range("AJ30").End(xlUp).Offset(1, 0).PasteSpecial
    Application.CutCopyMode = False
    
    
ElseIf Escala < Inicio Or Escala > Final Then
    Range("AB2" & linha & ":AI2" & linha).Copy
    Range("AR30").End(xlUp).Offset(1, 0).PasteSpecial
    Application.CutCopyMode = False
    linha = linha + 1
     Afasta = Range("AB2").Value & linha
    Inicio = Range("AG2").Value & linha
    Final = Range("AH2").Value & linha
MsgBox "AFASTAMENTOS ATUALIZADOS", vbInformation, ""
Else
MsgBox "Não Há Afastamentos", vbInfomation, ""

End If
          linha = linha + 1
    Afasta = Range("AB2" & linha).Value
    Inicio = Range("AG2" & linha).Value
    Final = Range("AH2" & linha).Value
 Loop
    

End Sub

'After that in the distance field of the scale I link with the cells AJ1:AQ30 bringing 'thus the desired results

Browser other questions tagged

You are not signed in. Login or sign up in order to post.