Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
How can I use both .Hyperlink.Add Address with .Formula on VBA?

Greetings for everyone!

Introduction.

At the work, we use an electronic document management web application (we can name it for example as "webdocs") that allows us to search the documents by their specific number.

The "webdocs" have an option to download an excel file to show the list of expired and coming outer/internal documents.

That excel file has the column which consists № character + document number + line break + date of entry.

The webdocs.

When I search a document, the URL looks like the following: https://webdocs.com/#!/cancelar/incoming/document_list_organization?page=1&document_recipient_reg_number=12345678&boss=-1&from_date=01.01.2022&to_date=12.31.2022&year=2022

So the URL consists 3 main blocks, the second one is what I am looking for:

  1. Protocol HTTPS + Domain + Documents area + Visible page number;
  2. Document number (I wrote 12345678 as the placeholder);
  3. Specific filter + Date filter.

The problem

I wrote the VBA code that adds the additional column and it pasts the URL into each cell of the table of data.

The main point is to replace the second block of URL with the value of the column "B", that is why I have added a formula that ignores "№" character and takes the values until the line break (character 10).

Dim zRange, zCells As Range
Set zRange = .Range("I3", .Range("I3").End(xlDown)).Offset(0, 5)

.Range("N2").Value = "Find the document"

For Each zCells In zRange
  .Hyperlinks.Add Anchor:=zCells, _
  Address:="https://webdocs.com/#!/cancelar/incoming/document_list_organization?page=1&document_recipient_reg_number="
    & zCells.Formula = "RIGHT(LEFT(" & "B" & zCells.Row & ",FIND(CHAR(10)," & "B" & zCells.Row & ")-1), LEN(LEFT(" & "B" & zCells.Row & ",FIND(CHAR(10)," & "B" & zCells.Row & ")-1))-2)"
    & "&boss=-1&from_date=01.01.2022&to_date=12.31.2022&year=2022", _
  ScreenTip:="Open the document", _
  TextToDisplay:="Open the document"
Next zCells

The code interprets the ".Formula" as text and when I opened the hyperlink, I saw the formula on the URL's second block but not the value from the cells of the column "B". The code does not work as it should.

The question

What is the way to fix the problem?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Hint:

Sub TestA()
Const Address As String = "https://webdocs.com/#!/cancelar/incoming/document_list_organization?page=1&document_recipient_reg_number=12345678&boss=-1&from_date=01.01.2022&to_date=12.31.2022&year=2022"
MsgBox "Reg #: " & Split(Split(Address, "=")(2), "&")(0)
End Sub

Likewise:

Sub TestB()
Dim DocID As String
DocID = Range("B" & zCells.Row).Text
MsgBox "Reg #: " & Split(Split(DocID, "№")(1), Chr(10))(0)
End Sub
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda