AUTO MACROS

KIDNEE34

New Member
Joined
Dec 18, 2005
Messages
9
this the code i have for a macro that i want to auto run when i open the page up can someone help me out with this
thank you
Sub findandreplace()
'
' findandreplace Macro
' Macro recorded 12/15/2005 by
'
' Keyboard Shortcut: Ctrl+y
'

Cells.Replace What:="boston celtics", Replacement:="bos", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D3:E3").Select
Selection.Copy
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Sacramento Kings"
Range("C3").Select
Cells.Replace What:="Sacrameto Kings", Replacement:="sac", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Sacrameto Kings", Replacement:="sac", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D1").Select
Cells.Replace What:="Sacrameto Kings", Replacement:="sac", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Los Angeles Lakers", Replacement:="lal", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Sacrameto Kings", Replacement:="sac", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Sacramento Kings", Replacement:="sac", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Los Angelas Clippers", Replacement:="sac", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Golden State Warriors", Replacement:="gst", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Los Angelas Clippers", Replacement:="lac", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Los Angeles Clippers", Replacement:="lac", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Phoenix Suns", Replacement:="phe", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="San Antonio Spurs", Replacement:="sas", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D9").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = " San Antonio Spurs"
Range("G9").Select
Cells.Replace What:="San Antonio Spurs", Replacement:="sas", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Memphis Grizzlies", Replacement:="mem", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Dallas Mavericks", Replacement:="dal", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="New Orleans Hornets", Replacement:="norl", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Houston Rockets", Replacement:="hou", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("E17").Select
ActiveCell.FormulaR1C1 = ""
Range("D17").Select
ActiveCell.FormulaR1C1 = "Minnesota Timberwolfes"
Range("F17").Select
Cells.Replace What:="Minnesota Timberwolves", Replacement:="min", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("E:E").ColumnWidth = 10.43
Columns("E:E").ColumnWidth = 11
Cells.Replace What:="Minnesota Timberwolves", Replacement:="min", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Minnesota Timberwolfves", Replacement:="min", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D17").Select
ActiveCell.FormulaR1C1 = "Minnesota Timberwolfves"
Cells.Replace What:="Minnesota Timberwolfves", Replacement:="min", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Denver Nuggets", Replacement:="den", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Seattle Supersonics", Replacement:="sea", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D20").Select
Cells.Replace What:="Utah Jazz", Replacement:="uta", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("D21").Select
ActiveCell.FormulaR1C1 = "Portland Trail Blazers "
Range("E21").Select
Cells.Replace What:="Portland Trail blazers", Replacement:="por", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("F25").Select
Cells.Replace What:="Philadelphia 76ers", Replacement:="phi", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="New Jersey Nets", Replacement:="nj", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="New York Knicks", Replacement:="ny", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Toronto Raptors", Replacement:="tor", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Detroit Pistons", Replacement:="det", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Cleveland Cavaliers", Replacement:="cle", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Indiana Pacers", Replacement:="ind", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Milwaukee Bucks", Replacement:="mil", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Chicago Bulls", Replacement:="chi", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Miami Heat", Replacement:="mia", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Washington Wizards", Replacement:="was", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Orlando Magic", Replacement:="orl", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Charlotte Bobcats", Replacement:="cha", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Cells.Replace What:="Atlanta Hawks", Replacement:="atl", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub
 

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Nogslaw

Well-known Member
Joined
Jul 9, 2004
Messages
904
If you want it to run every time you select the desired sheet, then I believe you need to place the code in the Worksheet_Activate command.

Right click the sheet tab, and click on view code. Use the dropdown boxes to select Worksheet and Activate. Paste the body of the code in there.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,908
Messages
5,574,965
Members
412,630
Latest member
Eireangel
Top