Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda