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 WarleySCCCO
Posts
#53398
Olá Gurus, estou com problema que eu não tenho a minima ideia como resolver.

O sistema está pronto, o arquivo a qual acesso fica em pasta servidor. Ao abri-lo na minha maquina o Arquivo roda redondo. O meu Excel é 2007. Porém as outras maquinas com Excel 2013 estão dando erro na hora de cadastrar um novo registro.
Editado pela última vez por WarleySCCCO em 03 Abr 2020 às 16:46, em um total de 1 vez.
Avatar do usuário
Por AfonsoMira
Posts Avatar
#53421
Boa tarde.
Penso que o erro estava onde iria definir a ultima linha pois ele ao invés de estar a gravar o número da linha estava a gravar o valor da ultima linha como aqui tinha "90909090909090" ele não ia encontra esta linha pois excede o limite de linhas do excel.

Modifiquei esta parte do seu código para ele encontrar a ultima linha:

Antes:
Código: Selecionar todos
  Dim Linha As Object
  Set Linha = Plan1.Range("A1000").End(xlUp)
 
  'Gravar
  Linha.Offset(1, 0).Value = Txtsei.Text
  Linha.Offset(1, 1).Value = Txtnumero.Text
  Linha.Offset(1, 2).Value = Txtdatareg.Text
  Linha.Offset(1, 3).Value = Txtservidor.Text
  Linha.Offset(1, 4).Value = Txtdatache.Text
  Linha.Offset(1, 5).Value = Txtmeio.Text
  Linha.Offset(1, 6).Value = Txtremetente.Text
  Linha.Offset(1, 7).Value = Txtoperacao.Text
  Linha.Offset(1, 8).Value = txtassunto.Text
  Linha.Offset(1, 9).Value = Txtorcliente.Text
  Linha.Offset(1, 10).Value = Txtsolicitacao.Text
  Linha.Offset(1, 11).Value = Txtalvo.Text
  Linha.Offset(1, 12).Value = Txtdataven.Text
  Linha.Offset(1, 13).Value = Txtresumo.Text
  Linha.Offset(1, 14).Value = Txtsituacao.Text
  Linha.Offset(1, 15).Value = Txtdestino.Text
  Linha.Offset(1, 16).Value = Txtseisaida.Text
  Linha.Offset(1, 17).Value = Txtdistribuidopara.Text
  Linha.Offset(1, 18).Value = TxtNrelatorio.Text
Depois:
Código: Selecionar todos
Dim Linha As Long
  
'Encontra ultima linha com valor e adiciona uma
  Linha = Plan1.Range("A1000").End(xlUp).Row + 1
 
  'Gravar
'Cells(variavel linha, coluna)
  Cells(Linha, 1).Value = Txtsei.Text
  Cells(Linha, 2).Value = Txtnumero.Text
  Cells(Linha, 3).Value = Txtdatareg.Text
  Cells(Linha, 4).Value = Txtservidor.Text
  Cells(Linha, 5).Value = Txtdatache.Text
  Cells(Linha, 6).Value = Txtmeio.Text
  Cells(Linha, 7).Value = Txtremetente.Text
  Cells(Linha, 8).Value = Txtoperacao.Text
  Cells(Linha, 9).Value = txtassunto.Text
  Cells(Linha, 10).Value = Txtorcliente.Text
  Cells(Linha, 11).Value = Txtsolicitacao.Text
  Cells(Linha, 12).Value = Txtalvo.Text
  Cells(Linha, 13).Value = Txtdataven.Text
  Cells(Linha, 14).Value = Txtresumo.Text
  Cells(Linha, 15).Value = Txtsituacao.Text
  Cells(Linha, 16).Value = Txtdestino.Text
  Cells(Linha, 17).Value = Txtseisaida.Text
  Cells(Linha, 18).Value = Txtdistribuidopara.Text
  Cells(Linha, 19).Value = TxtNrelatorio.Text
Envio o ficheiro modificado em anexo.

Caso tenha alguma dúvida baste dizer.

Se consegui ajudar não se esqueça de clicar em obrigado :D
Você não está autorizado a ver ou baixar esse anexo.
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