
ADD HIPERLINK CON EMAIL ADDRESS
Publicado por Eduardol (10 intervenciones) el 01/09/2021 05:58:17
Hola amigos, tengo un problema con excel, he realizado una formula para generar automaticamente unos emails utilizando el metodo HIPERVINCULO, de la siguiente manera. =SI(R4="";"";HIPERVINCULO("mailto:"&C4&"?subject=Saldos Disponibles&body="&R4;"Enviar Email")) en donde R4 es el body del mail, es otra formula. El problema es que excel no puede resolver esta formula si la misma supera los 255 caracteres.
Por lo tanto he encontrado que la forma de sortear este inconveniente es haciendo una macro.
Mis conocimentos en esta materia son bastante limitados, pero puedo entender el codigo, y la primera parte del mismo, no es lo que necesito, sino que el evento que activa el codigo tiene que ser otro, como que cierta celda tenga un valor determinado.
Tambien me gustaria saber, si codigo de add subaddress se le puede agregar el body del email, y como?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 Then Exit Sub ' IF ITS A HEADER, DO NOTHING.
If Trim(Target.Text) <> "" Then
addHyperLink
End If
End Sub
Sub addHyperLink()
On Error GoTo ErrHandler
Application.ScreenUpdating = False
Dim myDataRng As Range
Dim cell As Range
Set myDataRng = Range("D1:D" & Cells(Rows.Count, "D").End(xlUp).Row)
Application.Worksheets("Sheet2").Columns(1).ClearContents
Application.Worksheets("Sheet2").Cells(1, 1) = "Critical Log"
For Each cell In myDataRng
If cell(myDataRng.Row, 1).Text < Val(cell(myDataRng.Row, 0).Text) Then
' ADD ADDRESS.
Application.ActiveSheet.Hyperlinks.Add _
Anchor:=Application.ActiveSheet.Cells(cell.Row, cell.Column + 1), _
Address:="mailto:[email protected]?subject=Sales Report", _
SubAddress:="", _
ScreenTip:="Critical", _
TextToDisplay:="Mail this Figure"
' ADD SUB-ADDRESS
Application.Worksheets("Sheet2").Hyperlinks.Add _
Anchor:=Application.Worksheets("Sheet2").Cells(cell.Row, 1), _
Address:="", _
SubAddress:=Application.ActiveSheet.Name & "!" & cell.Address, _
ScreenTip:="Critical", _
TextToDisplay:="Check Figure"
End If
Next cell
Set myDataRng = Nothing
ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Bueno, espero que alguien lea mi consulta y me ayude.
Muchas gracias!
Por lo tanto he encontrado que la forma de sortear este inconveniente es haciendo una macro.
Mis conocimentos en esta materia son bastante limitados, pero puedo entender el codigo, y la primera parte del mismo, no es lo que necesito, sino que el evento que activa el codigo tiene que ser otro, como que cierta celda tenga un valor determinado.
Tambien me gustaria saber, si codigo de add subaddress se le puede agregar el body del email, y como?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 Then Exit Sub ' IF ITS A HEADER, DO NOTHING.
If Trim(Target.Text) <> "" Then
addHyperLink
End If
End Sub
Sub addHyperLink()
On Error GoTo ErrHandler
Application.ScreenUpdating = False
Dim myDataRng As Range
Dim cell As Range
Set myDataRng = Range("D1:D" & Cells(Rows.Count, "D").End(xlUp).Row)
Application.Worksheets("Sheet2").Columns(1).ClearContents
Application.Worksheets("Sheet2").Cells(1, 1) = "Critical Log"
For Each cell In myDataRng
If cell(myDataRng.Row, 1).Text < Val(cell(myDataRng.Row, 0).Text) Then
' ADD ADDRESS.
Application.ActiveSheet.Hyperlinks.Add _
Anchor:=Application.ActiveSheet.Cells(cell.Row, cell.Column + 1), _
Address:="mailto:[email protected]?subject=Sales Report", _
SubAddress:="", _
ScreenTip:="Critical", _
TextToDisplay:="Mail this Figure"
' ADD SUB-ADDRESS
Application.Worksheets("Sheet2").Hyperlinks.Add _
Anchor:=Application.Worksheets("Sheet2").Cells(cell.Row, 1), _
Address:="", _
SubAddress:=Application.ActiveSheet.Name & "!" & cell.Address, _
ScreenTip:="Critical", _
TextToDisplay:="Check Figure"
End If
Next cell
Set myDataRng = Nothing
ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Bueno, espero que alguien lea mi consulta y me ayude.
Muchas gracias!
- Enviado-de-Mails-macro-excel.zip(25,1 KB)
Valora esta pregunta


0