Ændring af font i Excel 2000 engelsk ved brug af VBA
Er der nogen der kan hjælpe mig.Jeg skal have excel til at søge på en font og størrelse og erstatte det med en anden font og størrelse. macroen skal søge hele filen igennem og erstatte Times New Roman "12" med arial "10" og Times New Roman "16" med arial "14"
Jeg har fået det til at virke i Excel XP med denne kode (der skal selvfølgelig anvendes en call fuktion når macroen bliver endelig, men lige nu skal jeg bare have det til at virke under 2000).
Sub style()
'Establish search criteria.
With Application.FindFormat.font
.Name = "Times New Roman"
.Size = 12
End With
' Establish replacement criteria.
With Application.ReplaceFormat.font
.Name = "Arial"
.Size = 10
End With
' Notify user.
With Application.ReplaceFormat.font
MsgBox "Times New Roman vil nu blive erstattet af Arial.", [vbOKOnly], "Connected thinking."
End With
Application.Run "OntimeLogging"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True
'Establish search criteria.
With Application.FindFormat.font
.Name = "Times New Roman"
.Size = 16
End With
' Establish replacement criteria.
With Application.ReplaceFormat.font
.Name = "Arial"
.Size = 14
End With
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True
End Sub