Anzeige
Archiv - Navigation
1348to1352
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Bitte um Hilfe bei Makro, das Hyperlinks sucht

Bitte um Hilfe bei Makro, das Hyperlinks sucht
08.02.2014 21:38:04
Christian
Hallo alle zusammen,
habe unten stehendes Makro, welches so weit auch funktioniert.
In dem Makro wird u.a. überprüft ob 2 Zellen in Tabelle Hyperlinks in derselben Zelle in Tabelle4 vorkommt.
Ich würde mir wünschen, dass zukünftig nur noch der Text in Tabelle4 Spalte D überprüft wird, nicht mehr wie bislang Spalte B und C.
Bitte helft mir dabei.
DAnke
Christian
Option Explicit
Public Sub SearchHyperlinks()
Dim lngRow As Long
Dim objCell As Range
Dim objRegEx As Object, objMatch As Object
Dim strSearchName As String, strFoundName As String
Dim strFirstAddress As String, strHyperlinkAddress As String
Dim strSearch2 As String
With Application
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
Set objRegEx = CreateObject("VBScript.RegExp")
With Worksheets("Hyperlinks")
For lngRow = 1 To .Cells(.Rows.Count, 2).End(xlUp).row
strSearchName = Trim$(.Cells(lngRow, 2).Value)
strSearch2 = Trim$(.Cells(lngRow, 3).Value)
If strSearchName  vbNullString Then
With Worksheets("Tabelle4")
Set objCell = .Columns(1).Find(What:=strSearchName, _
After:=.Cells(.Rows.Count, 1), _
LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)
End With
If Not objCell Is Nothing Then
strFirstAddress = objCell.Address
Do
If objCell.Hyperlinks.Count  0 _
And InStr(1, objCell.Text, strSearch2) > 0 Then
If InStr(objCell.Hyperlinks.Item(1).Address, "profile.php") Then
strHyperlinkAddress = Split(objCell.Hyperlinks.Item(1).Address, "&")(0)
Else
strHyperlinkAddress = Split(objCell.Hyperlinks.Item(1).Address, "?")(0)
End If
strFoundName = Trim$(objCell.Value)
If strFoundName  strSearchName Then
With objRegEx
.IgnoreCase = True
.Pattern = "^" & strSearchName & " | " & strSearchName & "$" _
_
_
_
Set objMatch = .Execute(strFoundName)
End With
If objMatch.Count = 1 Then
If objMatch.Item(0).Value = strSearchName & " " Or _
objMatch.Item(0).Value = " " & strSearchName Then _
Call WriteLink(strHyperlinkAddress, lngRow)
End If
Else
Call WriteLink(strHyperlinkAddress, lngRow)
End If
End If
Set objCell = Worksheets("Tabelle4").Columns(1).FindNext(objCell) ' _
Loop Until objCell.Address = strFirstAddress
End If
End If
Next
End With
Set objCell = Nothing
Set objMatch = Nothing
Set objRegEx = Nothing
With Application
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Private Sub WriteLink( _
ByVal pvstrHyperlinkAddress As String, _
ByVal pvlngRow As Long)
Dim lngColumn As Long
Dim blnFound As Boolean
With Worksheets("Hyperlinks")
For lngColumn = 3 To .Cells(pvlngRow, .Columns.Count).End(xlToLeft).Column
If .Cells(pvlngRow, lngColumn).Value = pvstrHyperlinkAddress Then
blnFound = True
Exit For
End If
Next
If Not blnFound Then
lngColumn = WorksheetFunction.Max(4, _
.Cells(pvlngRow, .Columns.Count).End(xlToLeft).Column + 1)
.Cells(pvlngRow, lngColumn).Value = pvstrHyperlinkAddress
End If
End With
End Sub

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
  • 09.02.2014 09:31:59
    Hajo_Zi
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige