2016-04-15 11 views

Antwort

1

Das Problem liegt in der fehlenden Value-Eigenschaft neben dem Bereich in Ihrer Schleife. Es sollte lesen,

y.Sheets(1).Range(“A” & i).Value = x.Sheets(i).Name 

Ich gehe davon aus, dass Sie bewusst Arbeitsblatt Namen Kopieren starten gewählt aus i = 3. Wenn Sie alle Arbeitsblätter benötigen, nur den Wert von i 1.

ändern versuchen Sie dies:

Sub CopyWorkBookNames() 
Application.ScreenUpdating = False 'To avoid screen flickering 

Dim y As Workbook 
Dim x As Workbook 

Set y = Application.ActiveWorkbook 
Set x = Application.Workbooks.Open("FilePathToCopyFrom.xlsx") 

'Copy and paste worksheet names, in the workbook running the code, starting from cell A3. 
'If You want to paste into cell A1, decrement i in the range below accordingly 

For i = 3 To x.Sheets.Count 
    y.ActiveSheet.Range("A" & i).Value = x.Sheets(i).Name 
Next i 

x.Close 'Add SaveChanges Options as needed 
Application.ScreenUpdating = True 
End Sub 
+0

Cool! Ja, der Wert fehlt. Funktioniert perfekt. Danke –

Verwandte Themen