user3715260
user3715260

Reputation: 1

Run vb-code for every sheet in workbook

I would like to tweak this code, so that it: - REPLACES all images with their AlternativeText - Runs for all worksheets in the workbook

    Dim Pic As Picture
    Dim Cell As Range
    For Each Pic In ActiveSheet.Pictures
        Set Cell = Pic.TopLeftCell.Offset(, -1)
        Do
            If Cell.Value = "" Then
                Cell.Value = Pic.ShapeRange.AlternativeText
                Exit Do
            Else
                Set Cell = Cell.Offset(1)
            End If
        Loop
    Next Pic
End Sub 

Can you please think with me on this one? Thank you very much in advance!

Upvotes: 0

Views: 187

Answers (1)

MatthewHagemann
MatthewHagemann

Reputation: 1195

To loop through all sheets in a workbook use:

For s = 1 to ActiveWorkbook.Worksheets.Count
    Sheets(s).Activate

    'Enter code to be run on each worksheet here

Next s

Upvotes: 1

Related Questions