Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's my code:
Set ofound = Cells.Find(WHAT:="EXT", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=True) If Not ofound Is Nothing Then ofound.Activate If Trim(ofound) = "EXT" Then ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate Selection.Copy Windows("BOOK1.XLS").Activate Range("D3").Select ActiveSheet.Paste I want to find the word EXT in column A only, how do i narrow my search down????? here is another EXT in Column C that it is referencing. I need column A... --- Message posted from http://www.ExcelForum.com/ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Only look in column A might be a start
Cells.Find(WHAT:="EXT" would be Columns(1).Find(WHAT:="EXT" -- Regards, Tom Ogilvy "alexm999 " wrote in message ... Here's my code: Set ofound = Cells.Find(WHAT:="EXT", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=True) If Not ofound Is Nothing Then ofound.Activate If Trim(ofound) = "EXT" Then ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate Selection.Copy Windows("BOOK1.XLS").Activate Range("D3").Select ActiveSheet.Paste I want to find the word EXT in column A only, how do i narrow my search down????? here is another EXT in Column C that it is referencing. I need column A... --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works Great thanks!
But... What if the word EXT is not there? depending on the day, EXT may no show up. how can i get it to search for EXT and then if not found, mov on to the next search, but if found run the script i listed above. -- Message posted from http://www.ExcelForum.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Guess you didn't write any of this code, because it is pretty much is set up
to act the way you describe. Dim oFound as Range Set ofound = Columns(1).Find(WHAT:="EXT", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=True) If Not ofound Is Nothing Then ' this is only run if EXT is found ofound.Activate If Trim(ofound) = "EXT" Then ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate Selection.Copy Windows("BOOK1.XLS").Activate Range("D3").Select ActiveSheet.Paste Application.goto oFound End if ' trim(ofound) = "EXT" End if ' Not ofound is Nothing the test, IF not ofound is nothing then only does the above copy and paste if a cell with EXT was found in column 1. Otherwise it drops down to the End If and if the code after that is another search, it would do that. I indented the code in the If Then; End if block to make that clearer. -- Regards, Tom Ogilvy "alexm999 " wrote in message ... Works Great thanks! But... What if the word EXT is not there? depending on the day, EXT may not show up. how can i get it to search for EXT and then if not found, move on to the next search, but if found run the script i listed above.. --- Message posted from http://www.ExcelForum.com/ |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The clue is to decide if you want to do two searches or one and if that ends
up blank then another. That determins to in clude in end if statement or not. Carl "Tom Ogilvy" wrote in message ... Guess you didn't write any of this code, because it is pretty much is set up to act the way you describe. Dim oFound as Range Set ofound = Columns(1).Find(WHAT:="EXT", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=True) If Not ofound Is Nothing Then ' this is only run if EXT is found ofound.Activate If Trim(ofound) = "EXT" Then ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate Selection.Copy Windows("BOOK1.XLS").Activate Range("D3").Select ActiveSheet.Paste Application.goto oFound End if ' trim(ofound) = "EXT" End if ' Not ofound is Nothing the test, IF not ofound is nothing then only does the above copy and paste if a cell with EXT was found in column 1. Otherwise it drops down to the End If and if the code after that is another search, it would do that. I indented the code in the If Then; End if block to make that clearer. -- Regards, Tom Ogilvy "alexm999 " wrote in message ... Works Great thanks! But... What if the word EXT is not there? depending on the day, EXT may not show up. how can i get it to search for EXT and then if not found, move on to the next search, but if found run the script i listed above.. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Quick Code | Excel Discussion (Misc queries) | |||
Quick! Help With Code Formatting! | Excel Programming | |||
quick code request | Excel Programming | |||
quick code question | Excel Programming | |||
Is there a quick way to see which objects have code attached? | Excel Programming |