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
#16046
Pessoal é o seguinte...
Estou com dificuldades com o seguinte código...
Código: Selecionar todos
Sub CriarArquivo()
'
' CriarArquivo Macro
'

'
    Range("B1").Select
    ActiveCell.FormulaR1C1 = ActiveCell.Value + 1

    ActiveWorkbook.SaveAs Filename:= _
        "C:\Users\Artes\Desktop\teste\" & Mid(ActiveCell.Value, 7, 4) & "_" & Mid(ActiveCell.Value, 4, 2) & "_" & Mid(ActiveCell.Value, 1, 2) & ".xlsm", FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Podemos ver que é um código onde cria um novo arquivo e muda a data do mesmo, certo?
Só que ao invés de Criar um novo arquivo eu precisaria que ele criasse várias abas no mesmo arquivo, conseguem me compreender?
Vou anexar a planilha que eu estou utilizando.
Obrigado desde já. ;) ;)
#16059
Boa tarde!!

Seria algo como isso?
Código: Selecionar todos
Sub AleVBA_3216()
    Dim i As Integer
    Dim ws As Worksheet
    Dim sh As Worksheet
    
    Set ws = Sheets("02")    'Considerando que há essa guia de nome "02"
    Set sh = Sheets("Nomes") 'Considerando que há essa guia de nome "Nomes"
    
    Application.ScreenUpdating = 0
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
        Sheets("02").Copy After:=sh
        ActiveSheet.Name = sh.Range("A" & i).Value
    Next i
    Application.ScreenUpdating = 1
End Sub
Att
#16098
Pra você entender melhor Alexandre, anexei a planilha pronta aqui.
Abra ela, em seguida abra o editor VBA e altere o local que o novo arquivo será salvo, e salve as alterações.
Depois vá na planilha e Pressione CTRL+R pra você ver o que acontece.
#16178
Bom dia!!

Tente isso!
Código: Selecionar todos
Sub AleVBA_3216()
Dim sName As String
Dim i As Integer
Set ws = Sheets(Sheets.Count)
i = ActiveWorkbook.Worksheets.Count

sName = Mid([D1].Value, 7, 4) & "_" & Mid([D1].Value, 4, 2) & "_" & Mid([D1].Value, 1, 2) 'Application.InputBox("Digite o nome da guia", "Espelho")
If sName = "" Then Exit Sub
ws.Copy after:=Worksheets(i)
[D1].FormulaR1C1 = [D1].Value + 1
ActiveSheet.Name = sName

End Sub
Att
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