Hi, I'm trying to write a code in VBA to do a mass find/replace. Basically I want certain words to be replaced with numbers instead. However, I keep getting a syntax error and I can't see where. Here is the code:
Can someone please help?Sub Multi_FindReplace()'PURPOSE: Find & Replace a list of text/values throughout entire workbook'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
Dim sht As Worksheet
Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long
fndList = Array(”AIRE”, ”ASIAN FOODS”, ”BABY - BASICS”, ”BABY - E”, ”BABY - NAPPIES”, ”BABY FOOD”, ”BABY FORMULA”, ”BBQ”, ”BISCUITS - CHOCOLATE”, ”BISCUITS - CRISPBRD & *******”, ”BISCUITS - MULTIPACK”, ”BISCUITS - PLAIN & FANCY”, ”BISCUITS - SNACKING”, ”BRANCH REQUISITES”, ”BRD MIX”, ”BRKFAST - CERLS”, ”BRKFAST - MUESLI & OATS”, ”CAKE MIX & BAKING AIDS”, ”CANNED FISH”, ”CANNED FRUIT”, ”CANNED VEGETABLES”, ”CHEESE PRE-PACKED ENTERTAINING”, ”CHIPS - MULTIPACKS”, ”CHIPS - SHARING”, ”CLNERS”, ”COFFEE”, ”CONES & TOPPINGS & WATERICES”, ”CONFECTIONERY - BARS”, ”CONFECTIONERY - BLOCKS”, ”CONFECTIONERY - CHOC BITES”, ”CONFECTIONERY - GIFTING”, ”CONFECTIONERY - GUM & MEDICATED”, ”CONFECTIONERY - NOVELTY”, ”CONFECTIONERY - SHAREPACKS”, ”CONFECTIONERY - SUGAR”, ”COOK IN SAUCES”, ”COOKING OILS”, ”CORDIAL”, ”COSMETICS”, ”DEODORANT & TALC”, ”DIET & SPORT NUTRITION”, ”DINNERWARE”, ”DISHWASHING DETERGENT”, ”DISINFECTANTS”, ”DISPOSABLE PICNICWARE”, ”DRIED FRUIT & NUTS”, ”ELECTRICAL”, ”EUROPN FOODS”, ”FAMILY SOCKS”, ”FAMILY UNDERWR”, ”FEMININE HYGIENE”, ”FLOUR”, ”FOOD STORAGE”, ”FOOD WRAPS BAGS AND STORAGE”, ”FRUIT JUICE - LONG LIFE”, ”GARBAGE BAGS”, ”GARDEN - E”, ”GLASSWARE”, ”GRAVY”, ”HAIR ACCESSORIES”, ”HAIR COLOUR”, ”HAIR E”, ”HLTH FOODS”, ”HOME IMPROVEMENT & MOTORING”, ”HOSIERY”, ”HOUSEHOLD CLNING”, ”HOUSEHOLD STORAGE”, ”INDIAN FOODS”, ”INSECTICIDES”, ”ISB SUPPLIES - DRY RAW MATERIAL”, ”JELLY & PUDDINGS”, ”******* TOOLS AND PREPARATION”, ”LAUNDRY - FABRIC E”, ”LAUNDRY - LIQUIDS”, ”LAUNDRY - POWDERS”, ”LAUNDRY - SOAKERS & BLCH”, ”LONGLIFE MILK & SOY DRINKS”, ”LUNCH AND HYDRATION”, ”LUNCHBOX DRINKS”, ”MEDICINAL”, ”MENS TOILETRIES & RAZORS”, ”MEXICAN FOODS”, ”MILK ADDITIVES”, ”MUESLI BARS”, ”NEW ZLAND FOODS”, ”NOODLES”, ”ORAL E”, ”OVENWARE”, ”PAPER TOWEL”, ”PASTA SAUCE & CHEESE”, ”PASTA”, ”PERSONAL WASH”, ”PET NEEDS - CAT FOOD DRY”, ”PET NEEDS - CAT FOOD WET”, ”PET NEEDS - DOG FOOD DRY”, ”PET NEEDS - DOG FOOD WET”, ”PET NEEDS - DOG TRTS”, ”PET NEEDS - E & ACCESSORIES”, ”PET NEEDS - SMALL ANIMAL”, ”PREPARED MLS LONG LIFE”, ”PRINTER/INK”, ”RDY TO GO MLS”, ”RECIPE BASES”, ”RELISHES & PICKLES”, ”RESALE CAKE”, ”RESALE INTERNATIONAL BRD”, ”REUSABLE SHOPPING BAGS”, ”RICE”, ”SAUCES”, ”SHOE E”, ”SIDE DISHES”, ”SKIN E”, ”SMOKING ACCESSORIES”, ”SNACK - NUTS”, ”SOFT DRINKS - BOTTLES & CANS”, ”SOFT DRINKS - COLD DRINK”, ”SOFT DRINKS - ENERGY”, ”SOFT DRINKS - MINERAL WATER”, ”SOFT DRINKS - MIXERS”, ”SOFT DRINKS - SPORTS & ICE T”, ”SOFT DRINKS - WATER”, ”SOUP - CANNED”, ”SOUP - PACKET”, ”SPICES & COOKING NEEDS”, ”SPONGES/SCOURERS”, ”SPRDS - HONEY”, ”SPRDS - JAM”, ”SPRDS - OTHER”, ”SPRDS - PNUT BUTTER”, ”SPREADS - OTHER”, ”STATIONERY - BASIC”, ”SUGAR”, ”SUN E”, ”T AND COFFEE ACCESSORIES”, ”T”, ”TECH”, ”TISSUES”, ”TOILET CLNERS”, ”TOILET ROLLS”, ”TOYS”, ”UK AND IRISH FOODS”, ”VINEGAR MAYO & DRESSINGS”, ”WRAPPING - BAKEHOUSE”)
rplcList = Array("12", "5", "10", "9", "9", "10", "10", "11", "2", "2", "2", "2", "2", "99", "7", "1", "1", "7", "6", "6", "6", "98", "5", "5", "12", "2", "6", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "3", "10", "9", "9", "7", "13", "12", "7", "7", "8", "5", "7", "7", "10", "7", "7", "97", "3", "12", "11", "7", "5", "10", "10", "10", "1", "11", "8", "13", "12", "5", "11", "96", "6", "7", "12", "12", "12", "12", "22", "7", "3", "9", "9", "5", "2", "1", "5", "5", "9", "7", "12", "5", "5", "9", "11", "11", "11", "11", "11", "11", "11", "6", "8", "6", "5", "6", "95", "94", "93", "5", "6", "12", "6", "10", "92", "4", "3", "91", "44", "3", "3", "44", "3", "6", "6", "5", "13", "1", "1", "1", "1", "1", "8", "6", "10", "2", "2", "8", "9", "13", "12", "8", "5", "6", "90")
'Loop through each item in Array lists
For x = LBound(fndList) To UBound(fndList)
'Loop through each worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace What:=fndList(x), Replacement:=rplcList(x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
Next x
End Sub