Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por kleinowski
Posts
#38497
Quero definir a área de impressão por VBA.
A questão é que a quantidade de linhas de cada planilha pode aumentar ou diminuir.
Para resolver isso tenho o seguinte código:
Range("G1").End(xlDown).Offset(1, 0).Select
Com isso ele já resolve o meu problema.

O que eu preciso é que a minha área de impressão seja da A5 até a ultima linha da coluna G.
Como faço isso?
Avatar do usuário
Por fcarlosc2018
Posts Avatar
#38499
Veja se é assim:
Código: Selecionar todos
Sub DefinirAreaImpressao()

Dim Ultimalinha As Integer

 Worksheets("Plan1").Select
 
     Ultimalinha = ThisWorkbook.Worksheets("Plan1").Range("G1000").End(xlUp).Offset(0, 7).Row
     Range("A5:E1000").SpecialCells(xlCellTypeConstants).Select
     Range("A5:G" & Ultimalinha).Select
     ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False

End Sub
Por osvaldomp
#38500
Código: Selecionar todos
Sub ImprimePlanilhaAtiva()
 With ActiveSheet
  .PageSetup.PrintArea = "$A$5:$G" & .Cells(Rows.Count, "G").End(3).Row
  .PrintOut
 End With
End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord