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
#60260
Bom dia! Procurei bastante mas não consegui resolver.

Consegui fazer 2 variaveis.
Comecorng pega a primeira celula que quero colocar na formula (no meu caso J3)
Fimrng pega a ultima linha desta coluna que contem numero. (tanto a J3 como a final podem variar de linha)

consegui levar o cursor até onde eu quero somar esta range. (nao posso simplesmente colocar a formula la porque ela tb varia de acordo com os itens que tem na tabela.

VB

Sub RangeEquip()
Dim comecorng As Variant
Dim fimrng As Variant
Dim x
Set Procurar = Cells.Find(What:="Equip.", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not (Procurar Is Nothing) Then
Procurar.Select

ActiveCell.Offset(1, 9).Select
comecorng = ActiveCell.Address
Selection.End(xlDown).Select
fimrng = ActiveCell.Address

Set ProcurarTotEquip = Cells.Find(What:="Total Equipamentos", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not (ProcurarTotEquip Is Nothing) Then
ProcurarTotEquip.Select
ActiveCell.Offset(0, 7).Select

'@@@@@@@@@@ Aqui deveria inserir a formula @@@@@@@@@@@@@@@@@@@
ActiveCell.Value = "=" & "(" & comecorng & ":" & fimrng & ")"

End If
End If

End Sub

mas o que me aparece la na celula é =(@$J$13:$J$14) na barra de formulas e na celula @VALOR

Alguém poderia me auxiliar.

Grato
#60264
A formula que você quer é a de SOMA certo?
#60265
Veja se é assim:
Código: Selecionar todos
Sub RangeEquip()
Dim comecorng As Variant
Dim fimrng As Variant
Dim x
Set Procurar = Cells.Find(What:="Equip.", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not (Procurar Is Nothing) Then
Procurar.Select

ActiveCell.Offset(1, 9).Select
comecorng = ActiveCell.Address
Selection.End(xlDown).Select
fimrng = ActiveCell.Address

Set ProcurarTotEquip = Cells.Find(What:="Total Equipamentos", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not (ProcurarTotEquip Is Nothing) Then
ProcurarTotEquip.Select
ActiveCell.Offset(0, 7).Select

'@@@@@@@@@@ Aqui deveria inserir a formula @@@@@@@@@@@@@@@@@@@
ActiveCell.Value = "=SOMA(" & comecorng & ":" & fimrng & ")"

End If
End If

End Sub
#60273
Tem como disponibilizar o ficheiro para poder ajudar melhor?
Caso não possa crie um de exemplo com dados ficticios.

Obrigado. :)
#60275
vou mandar, a senha para entrar é PAULO senha 12 a macro esta no modulo 1
esta é teste alguns comandos alipodem não estar funcionando, preciso mesmo que a PLANILHA1 atualize esta informação.
Você não está autorizado a ver ou baixar esse anexo.
#60277
Experimente com esse:
Código: Selecionar todos
   Sub RangeEquip1()
Dim comecorng As Variant
Dim fimrng As Variant
Dim x
Set Procurar = Cells.Find(What:="Equip.", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not (Procurar Is Nothing) Then
Procurar.Select

ActiveCell.Offset(1, 9).Select
comecorng = ActiveCell.Address
Selection.End(xlDown).Select
fimrng = ActiveCell.Address

Set ProcurarTotEquip = Cells.Find(What:="Total Equipamentos", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not (ProcurarTotEquip Is Nothing) Then
ProcurarTotEquip.Select
ActiveCell.Offset(0, 7).Select

'@@@@@@@@@@ Aqui deveria inserir a formula @@@@@@@@@@@@@@@@@@@
ActiveCell.Value = "=SUM(" & comecorng & ":" & fimrng & ")"

End If
End If

End Sub
#60281
Então antes eu tinha metido assim: "=SOMA(" & comecorng & ":" & fimrng & ")" com a fórmula em português.
Então como deu erro tentei em inglês e deu certo.
andriessen agradeceu por isso
#60285
Por enquanto o botão resolvido está desabilitado.
Por isso não se preocupe assim que esteja habilitado de novo marcaremos como resolvido.
andriessen agradeceu por isso
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