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
Avatar do usuário
Por Nelisa
Posts Avatar
#21359
Olá,

tenho um userform em que o campo CÓDIGO é preenchido automaticamente, utilizando o código abaixo, e funciona perfeitamente, sendo apresentado sequencialmente (1,2,3.......)

No entanto, eu preciso que o mesmo seja composto com o ano, ficando assim (0001/2017)

Alguém poderia me orientar ?
Agradeço antecipadamente


Nelisa

Código: Selecionar todos
Private Sub UserForm_Initialize()

Range("A1").Select
While ActiveCell <> ""
If ActiveCell <> "CODIGO" Then
TextBoxCODIGO.Text = ActiveCell.Offset(0, 0).Value + 1
Else
TextBoxCODIGO.Text = 1
End If
ActiveCell.Offset(1, 0).Activate
Wend
End Sub
Por osvaldomp
#21364
Experimente:
Código: Selecionar todos
Private Sub UserForm_Initialize()
 Range("A1").Select
  While ActiveCell <> ""
   If ActiveCell <> "CODIGO" Then
    TextBoxCODIGO.Text = Format(ActiveCell.Value + 1, "0000") & "/" & Format(Date, "yyyy")
   Else
    TextBoxCODIGO.Text = Format(1, "0000") & "/" & Format(Date, "yyyy")
   End If
  ActiveCell.Offset(1, 0).Activate
  Wend
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