I am trying to write a macro that loops through the pages within a workbook, and anything that contains DR the name of the sheet should be put to sheet Macro and a content of a cell.
Sub FnGetSheetsName()
    Dim mainworkBook As Workbook
    Set mainworkBook = ActiveWorkbook
    For i = 1 To mainworkBook.Sheets.Count
        If mainworkBook.Sheets.Name.Contains("DR") Then
            mainworkBook.Sheets("Macro").Range("A" & i) = mainworkBook.Sheets.Name
            mainworkBook.Sheets("Macro").Range("B" & i) = mainworkBook.Sheets.Range("B17")
        End If
    Next i
End Sub
It stops at: If mainworkBook.Sheets.Name.Contains("DR") Then
Thanks for your answers! :) Tibor
 
     
     
     
     
    