VBA: Alle A1-Zellen in Arbeitsmappe kopieren und ausgeben?

2 Antworten

Auf die Schnelle zusammengestrickt:

Sub EinSatz()
Dim ws As Worksheet
Dim strAusgabe As String

For Each ws In ActiveWorkbook.Worksheets
  strAusgabe = strAusgabe & ws.Range("A1").Value
Next ws

MsgBox strAusgabe
End Sub

Teste mal

Woher ich das weiß:Berufserfahrung – IT-Administrator (i.R.)

dim text as string

text = empty

for each blatt in AktuellesWorkbook

Text = text & space(1) & blatt.cells(1,1)

next blatt

msgbox (text)

Woher ich das weiß:Berufserfahrung – Ich programmiere RPAs
dantes  12.11.2022, 20:00

Du kannst mit count auch die sheets zählen und dann als intmax zuweisen

for i = 1 to intmax

Text = text &space(1) & sheets(i).cells(1,1)

next i

0
dantes  12.11.2022, 20:02

Ach das ist alles pseudocode. Ich sitze gerade nicht sm computer. Du must nur blatt als sheet oder objekt dimensionieren und aktuellesworkbook set als thisworkbook

0
Hartzer4ever 
Fragesteller
 12.11.2022, 20:04

Danke dir. So einfach. Da hatte ich wohl einen ziemlichen Knoten im Kopf

Dim text As String

Dim blatt As Worksheet // Den Teil hattest du vergessen. Nur für den Fall, dass es noch mehr Menschen mit dem Problem gibt :)

text = Empty

For Each blatt In ThisWorkbook.Sheets

text = text & Space(1) & blatt.Cells(1, 1)

Next blatt

MsgBox (text)

   

End Sub

2