Notifications
Clear all

copiar formatos e valores

38 Posts
1 Usuários
0 Reactions
6,227 Visualizações
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Estou usando este código para copiar/colar parte de uma planilha , porem precisaria que fosse colado tambem a altura da linha pois a configuração das linhas "coladas" não está as mesmas da "copiada".

Tentei tambem com
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
mas não deu

Sub copiaCola()
Dim pl As Long
Dim ul As Long
Dim rng As Range
sht = ActiveSheet.Name
Set rng = Sheets(sht).Range("A2:Bh30")
rng.Select
Application.CutCopyMode = False
Selection.Copy

ul = Sheets(sht).Range("A65536").End(xlUp).Row
Sheets(sht).Range("A2:Bh30").Offset(ul - 1).Select ' determina para colar na primeira linha vazia
ActiveSheet.Paste

End Sub
 
Postado : 09/05/2012 7:26 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Sugestão (já que aparentemente todas as propostas não funcionaram).
Crie uma planilha em branco. Com o gravador de macro acionado, copie as linhas/celuas que deseja, e salve nessa planilha. Formate conforme o desejado (altura de linhas, largura de colunas, linhas etc...)Pare a gravação da macro. Nomeie essa planilha e a esconda. Qdo for copiar /adiconar outro modelo, utilize a macro gravada, que irá copiar os dados e formatar conforme desejado.

 
Postado : 04/06/2012 5:27 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Boa noite!!

Claudinei, nem sei mais o que tentar, vamos ver se o pessoal possa ajuda-lo pois não consigo encontrar resposta de modo que em seu Office e no seu PC, o que que está havendo.

Ainda pretendo ajuda-lo, mais meus conhecimentos são minúsculos para tal, vamos aguardar uma resposta melhor.

At++++

 
Postado : 04/06/2012 5:29 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

muito obrigado mesmo pelas ajudas

 
Postado : 07/06/2012 7:23 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Ainda no aguardo de uma solução , se alguem descobriu algo novo...

 
Postado : 20/06/2012 9:58 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Não ´foi a solução ideal , mas deu certo.

Sub copiaCola()
Desprot
Dim pl As Long
Dim ul As Long
Dim rng As Range
sht = ActiveSheet.Name
Set rng = Sheets(sht).Range("A2:Bh30")
rng.Select
Selection.Copy
ul = Sheets(sht).Range("A65536").End(xlUp).Row
Sheets(sht).Range("A2:Bh30").Offset(ul - 1).Select
ActiveSheet.Paste
pl = Sheets(sht).Range("A65536").End(xlUp).Row
Range("A" & pl - 28).Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
ActiveSheet.PageSetup.PrintArea = "$A$32:$M$" & pl '+ 1

Sheets(sht).Range("A100").Offset(ul - 99).Select
Selection.RowHeight = 60
Sheets(sht).Range("A100").Offset(ul - 98).Select
Selection.RowHeight = 33.75
Sheets(sht).Range("A100").Offset(ul - 97).Select
Selection.RowHeight = 28.5
Sheets(sht).Range("A100").Offset(ul - 96).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 95).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 94).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 93).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 92).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 91).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 90).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 89).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 88).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 87).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 86).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 85).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 84).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 83).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 82).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 81).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 80).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 79).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 78).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 77).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 76).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 75).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 74).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 73).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 72).Select
Selection.RowHeight = 58.5
Sheets(sht).Range("A100").Offset(ul - 71).Select
Selection.RowHeight = 63.75

Sheets(sht).Range("F100").Offset(ul - 96).Select
Prot
End Sub
 
Postado : 27/06/2012 10:01 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Como escrever esta parte do código , éééé .......... " de forma randomica? escrever usando menos informação , fazendo loop?
Já que somente a linha muda no código.

Sheets(sht).Range("A100").Offset(ul - 96).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 95).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 94).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 93).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 92).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 91).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 90).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 89).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 88).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 87).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 86).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 85).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 84).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 83).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 82).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 81).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 80).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 79).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 78).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 77).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 76).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 75).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 74).Select
Selection.RowHeight = 43.5
Sheets(sht).Range("A100").Offset(ul - 73).Select
Selection.RowHeight = 43.5
 
Postado : 27/06/2012 10:30 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Vc pode utilizar algo assim:
Sheets(sht).Rows("5:" & ul).Select 'onde 5 e a linha onde inicia e ul a linha onde termina a seleção
Selection.RowHeight = 43.5

 
Postado : 27/06/2012 11:14 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Muito obrigado Reinaldo e todos que colaboraram até aqui.

 
Postado : 27/06/2012 2:11 pm
Página 3 / 3