VBA/Excel/Access/Word/Forms/Replace — различия между версиями

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

Версия 16:33, 26 мая 2010

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
    Next
End Sub



Replacing with the Replace Method

 
Sub replace()
    ActiveSheet.Columns("B").Replace What:="Sales", _
        Replacement:="Sales & Marketing", SearchOrder:=xlByColumns, _
        MatchCase:=True
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