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.
#71302
Boa noite pessoal.
Eu estou adaptando um codigo VBA para criar abas e hiperlinks automaticamente de uma coluna.

Eu consegui adaptar ele e esta funcionando, porem ele soh funciona quando eu deixo o cursor no nome do novo cliente se por acaso o cursor estiver em qualquer outra celula e acionar o vba no botao azul...ele da problema.

1. tem como fazer o excel verificar sempre o novo cliente que for adicionado na coluna A independente de onde o cursor estiver?
2. na planilha modelo existe como ele criar a ABA jah com o nome do NOVO cliente no conteudo da planilha?

segue a planilha, imagem e o codigo

------
Sub add_new_sheet()


Dim sheet_name_to_create As String
Dim sh As Worksheet, nsh As Worksheet ' nsh = sheet_name_to_create
Dim nrng As Range
Dim cont As Worksheet
Dim oRng As Range


sheet_name_to_create = ActiveCell.Value

Set oRng = ActiveCell
Set sh = Sheets("Sheet1")


For rep = 1 To (Worksheets.Count)
If LCase(Sheets(rep).Name) = LCase(sheet_name_to_create) Then

MsgBox "this sheet already exists"
Exit Sub
End If

Next

Sheets("modelo").Visible = True
Sheets("modelo").Copy after:=Sheets(Sheets.Count)

Sheets(ActiveSheet.Name).Name = sheet_name_to_create

sh.Activate
sh.Hyperlinks.Add oRng, "", "'" & sheet_name_to_create & "'!A1", _
"Go to " & sheet_name_to_create, sheet_name_to_create

Set oRng = Nothing

End Sub
Você não está autorizado a ver ou baixar esse anexo.
#71304
Olá, @keshijp .

Experimente o código abaixo.
Código: Selecionar todos
Sub InsereCópiaDePlanilhaCriaHiperlink()
 Dim ws As Worksheet, c As Range
  Application.ScreenUpdating = False
  Set ws = ActiveSheet
  For Each c In ws.Range("A2:A" & ws.Cells(Rows.Count, 1).End(3).Row)
   If Evaluate("IsError('" & c.Value & "'!A1)") = True Then
    Sheets("modelo").Copy after:=Sheets(Sheets.Count)
    ActiveSheet.Name = c.Value
    ws.Hyperlinks.Add Anchor:=c, Address:="", SubAddress:= _
        "'" & c.Value & "'!A1"
   End If
 Next c
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