Материал из VB Эксперт
Перейти к: навигация, поиск

Replace information in all sheets of the workbook

Sub ChgInfo()
    Dim Sht As Worksheet
    For Each Sht In Worksheets
        Sht.Cells.Replace What:="old", Replacement:="new", LookAt:=xlPart, MatchCase:=False
End Sub

Replacing with the Replace Method

Sub replace()
    ActiveSheet.Columns("B").Replace What:="Sales", _
        Replacement:="Sales & Marketing", SearchOrder:=xlByColumns, _
End Sub

Using Replace to Replace Formatting

Sub ReplaceFormats() 
    " set formatting to look for 
    With Application.FindFormat 
        .Font.Bold = True 
        .Font.Size = 11 
    End With 
    " set formatting that should be applied instead 
    With Application.ReplaceFormat 
        .Font.Bold = False 
        .Font.Italic = True 
        .Font.Size = 8 
    End With 
    ActiveSheet.Cells.Replace What:="", Replacement:="", _ 
        SearchFormat:=True, ReplaceFormat:=True 
End Sub