How to assign the formula of cell D2 to a variable?

Asked

Viewed 3,002 times

1

CODE:

Range("AB2").Select
Dim tudo As String  
data_pasta = Format(Date, "/yy/mm/")

tudo = "https://pagina.pt/wp-content/imagens" & data_pasta & **D2** ".png"

ActiveCell.Value = tudo
ultima_linha = Range("A" & Rows.Count).End(xlUp).Row
Range("AB2").AutoFill Destination:=Range("AB2:AB" & ultima_linha)

EXAMPLE: https://pagina.pt/wp-content/imagens/17/31/1234122.png

  • Would you like the formula itself or the value it results in? I think it’s worth you explain your question a little better and explain step by step what is happening and what is in each cell or at least pass what is in the cells that will be used in the answer. The way you wrote it gets very abstract, giving room for answers that probably won’t solve your problem or won’t work.

  • I want to pass the value of cell A2 inside the variable everything as shown in the example.

2 answers

0


To get the cell value A2 use Range("A2").Value. You can replace your text ** A2 ** therefore, but do not forget to put the & before the ".png".

  • 1

    Gracias @Pedromvm!

0

REPLY: .Value

Range("AC2").Select
Dim tudo As String
data_pasta = Format(Date, "/yy/mm/")
tudo = "https://www.pagina.pt/wp-content/imagens" & data_pasta & Range("D2").Value & ".png"
ActiveCell.Value = tudo
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Range("AC2").AutoFill Destination:=Range("AC2:AC" & Lastrow)

Browser other questions tagged

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