How to concatenate or use & commercial with date and text?

Asked

Viewed 1,832 times

0

I am using the following code to present only the day and month.

Range("AB2").Select
ActiveCell.Value = "=Now()"
ActiveCell.NumberFormat = "yy/mm"
ultima_linha = Range("A" & Rows.Count).End(xlUp).Row
Range("AB2").AutoFill Destination:=Range("AB2:AB" & ultima_linha)

I want it to be presented as follows: text/17/31/text.
Some help on how to popular the fields?

2 answers

2

You can format the date in a variable and then assign the value in the cell:

Dim data As String
data = Format(Date, "dd/mm")
data = texto1 & "/" & data & "/" & texto2
ActiveCell.Value = data
  • I don’t understand Ricardo! So: date = "text1 & " / " date & " / " & text2"

  • I have to defer the strings : text1 = Ricardo; text2 = Punctual;

  • You have to define strings before using

  • I still don’t understand! The date value twice as a string?

  • How do I separate the "date" variable inside the string?

  • @b8engl the motivation behind assigning data = texto1 & "/" & data & "/" & texto2, that is to attribute to the variable data, the value of texto1, texto2 and again the variable value data, is to decrease the amount of ram memory used in the application... He could have done data_concatenada = texto1 & "/" & data & "/" & texto2, however, this result would be allocated to another memory address, thus making the program consume more memory at the time of its use.

Show 1 more comment

0

RESOLVED:

Range("AB2").Select
Dim tudo As String
data = Format(Date, "dd/mm")
tudo = "texto1/" & data & "/texto2"
ActiveCell.Value = tudo
ultima_linha = Range("A" & Rows.Count).End(xlUp).Row
Range("AB2").AutoFill Destination:=Range("AB2:AB" & ultima_linha)

Thanks in the same Ricardo Pontual!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.