Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have been using this particular macro for 12 years, including several months since I got Excel 2007 on my work computer. But something happened today that had me puzzled till I stepped through the macro and pinpointed the problem. My macro (snippet below) removes dashes and blanks from column B. Sub ReplaceStuff() Columns("B:B").Select Selection.Replace What:="-", Replacement:="", LookAt:=xlPart Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart End Sub Today, when I ran the macro, I discovered that it removed the dashes and blanks from the entire sheet (only a one-sheet workbook) instead of just the Selection. Then I remembered that a while back I was trying to create a macro to search an entire workbook but the code generated from the macro recorder didn't seem to have anything to specify the Sheet or the Workbook. Also, I had done a search earlier today and manually change the Within option to Workbook. Just as I suspected, when I manually changed the Within option back to Sheet, my macro functioned properly. I have two questions. Maybe they have the same answer. Is there a VBA way to restrict a search to the Selection regardless what the last choice was in the Find dialog? Is there a VBA way to search an entire workbook regardless what the last choice was in the Find dialog? Thanks, Francis (TheExcelAddict.com) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA Search Workbook Question (Excel 2007) | Excel Programming | |||
How do I do a File Search in Word or Excel 2007? | Excel Discussion (Misc queries) | |||
Excel 2007 - Workbook.Open Question | Excel Programming | |||
Excel search in cell - ecxel 2007 | Excel Worksheet Functions | |||
SEARCH AND REPLACE (in Excel 2007, beta) | Excel Programming |