Leonardo_Augusto Posted March 11, 2015 at 01:36 PM Report Share #579148 Posted March 11, 2015 at 01:36 PM Olá ! Preciso muito da ajuda de vocês, meu código abaixo lê os dados de uma planilha ,seleciona este e manda imprimir. Mas no momento eu precisaria repetir o código para funcionar pra cada cadastro(pessoa cadastrada). exemplo : Range("A5").Select .... Range("A6").Select ...... até o Range("A50").Select Lembrando que os dados podem aumentar .. Como posso otimizar para não precisar repetir o código abaixo para cada range? Sub Macro1() ' Macro1 Macro ' Atalho do teclado: Ctrl+i Sheets("Dados Pessoais").Select Range("A5").Select Selection.Copy Sheets("Folha de Pagamento").Select Range("I3").Select ActiveSheet.Paste Application.CutCopyMode = False Activewindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _ IgnorePrintAreas:=False Sheets("Dados Pessoais").Select Range("A6").Select Selection.Copy Sheets("Folha de Pagamento").Select Range("I3").Select ActiveSheet.Paste Application.CutCopyMode = False Activewindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _ IgnorePrintAreas:=False End Sub Link to comment Share on other sites More sharing options...
Wagner Morel Posted March 11, 2015 at 06:38 PM Report Share #579166 Posted March 11, 2015 at 06:38 PM Leonardo_Augusto, Boa Tarde! Você pode tentar assim: Sub Macro1() Dim i As Long Dim UltimaLinha As Long UltimaLinha = Sheets("Dados Pessoais").Cells(Cells.Rows.Count, 1).End(xlUp).Row ' Macro1 Macro ' Atalho do teclado: Ctrl+i For i = 5 To UltimaLinha Sheets("Dados Pessoais").Range("A" & i).Copy Destination:=Sheets("Folha de Pagamento").Range("I3") Activewindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False Next Application.CutCopyMode = False End Sub Link to comment Share on other sites More sharing options...
Leonardo_Augusto Posted March 16, 2015 at 04:55 PM Author Report Share #579554 Posted March 16, 2015 at 04:55 PM (edited) Como eu posso fazer para imprimir somente os registros filtrados?, por que nem sempre vou querer imprimir tudo! Edited March 17, 2015 at 12:42 PM by Leonardo_Augusto Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now