Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Makro für 4 Blätter

Forumthread: Makro für 4 Blätter

Makro für 4 Blätter
24.05.2024 12:57:21
Christian
Hallo, mal eine kurze Frage, ich weiß ich oute mich als ziemlichen VBA Abfänger.
Ich habe folgendes Makro gefunden, was auch zu 99% meinen Zweck erfüllt. Nur eine ganz blöde Frage,
wie schaffe ich es, dass dieses Makro nacheinander in Tabelle1, Tabelle2, Tabelle3 und Tabelle4 ausgeführt wird?
Musste es auf 4 Blätter aufteilen, da ansonsten die ca. 1 Mio Zeilen pro Spalte nicht ausreichen.
Geht doch bestimmt auch einfacher, als das Makro 4mal untereinander zu kopieren und jedesmal das Sheet zu ändern

Public Sub test()
Dim objIE As Object
Dim objLinks As Object
Dim objLink As Object
Dim lngCount As Long

Dim lloRow As Long, lshTab2 As Worksheet

Set lshTab2 = Sheets("Tabelle1")

For lloRow = 1 To lshTab2.Cells(lshTab2.Rows.Count, 1).End(xlUp).Row
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.navigate lshTab2.Range("A" & lloRow).Text
Do While .busy
Do While .busy
DoEvents
Loop
Loop
.Visible = False
Set objLinks = .Document.Links
For Each objLink In objLinks
lngCount = lngCount + 1
lshTab2.Cells(lngCount, 2) = objLink.href
lshTab2.Cells(lngCount, 3) = "'" & objLink.outertext
Next
.Quit
End With

Application.Wait ("00:00:05")
Next

Set objIE = Nothing
Set lshTab2 = Nothing

End Sub
Anzeige

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
das Makro nochmal in lesbarerer Form
24.05.2024 12:58:10
Christian
Public Sub test()

Dim objIE As Object
Dim objLinks As Object
Dim objLink As Object
Dim lngCount As Long

Dim lloRow As Long, lshTab2 As Worksheet

Set lshTab2 = Sheets("Tabelle1")

For lloRow = 1 To lshTab2.Cells(lshTab2.Rows.Count, 1).End(xlUp).Row
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.navigate lshTab2.Range("A" & lloRow).Text
Do While .busy
Do While .busy
DoEvents
Loop
Loop
.Visible = False
Set objLinks = .Document.Links
For Each objLink In objLinks
lngCount = lngCount + 1
lshTab2.Cells(lngCount, 2) = objLink.href
lshTab2.Cells(lngCount, 3) = "'" & objLink.outertext
Next
.Quit
End With

Application.Wait ("00:00:05")
Next

Set objIE = Nothing
Set lshTab2 = Nothing

End Sub
Anzeige
AW: das Makro nochmal in lesbarerer Form
24.05.2024 13:14:32
MCO
Mahlzeit!

Es sieht dann so aus



for Tabellenblatt = 1 to 4

Set lshTab2 = Sheets(Tabellenblatt )
Dein Makro,

next Tabellenblatt


Gruß ,MCO
AW: das Makro nochmal in lesbarerer Form
24.05.2024 13:21:25
Christian
Hallo MCO,

danke für die schnelle Hilfe.
Christian

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige