Jump to content

Ciclo em VBA com IF


valdemar21

Recommended Posts

Bom dia,

Estou a iniciar-me na programação com VBA e estou com um problema que não consigo solucionar. Vou colocar aqui o que pretendo para ver se alguém pode ajudar. Deste já muito obrigado.

Tenho os seguintes dados numa tabela Access:

Evento Centro Valor 20004773 1060.8 DCCGA00 88.4 DGRRG00 88.4 DMRAM00 88.4 DMRPM02 176.8 DRHAD02 88.4 DSADM02 88.4 DSADM04 88.4 DSAIP04 88.4 DSCIC00 88.4 DSPSD00 176.8 20004774 1060.8 CGAB002 81.6 DOISC04 81.6 DOISR00 81.6 DRHAD02 163.2 DSACL02 163.2 DSASG00 81.6 DSPEA00 163.2 DSPRE00 244.8

O que pretendo é efetuar a cópia do campo Evento para as celulas seguintes até encontrar a proxima celula preenchida.

Algo do género:

Dim x as Integer

lastRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row

For x = 1 To lastRow

If Cells(x, "A").Value = Null Then

Cells(x, "A").Value = Cells(x - 1, "A").Value

Else

Cells(x, "A").Value = Cells(x, "A").Value

End If

A questão é que em Excel estou a conseguir, mas quando tento em Access não consigo (as variaveis e definições devem ser diferentes)

Obrigado,

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.