Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I'm trying to write a macro to search for something then move one rwo and then delete two rows. I can do the search and the delete but I cannot do the move and the selecting of two rows! Any ideas please but I lose any more sleep? Thanks MB |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Post your code so we have some idea of what technique you are using to
search and so forth. -- regards, Tom Ogilvy "Pugwyrm" wrote in message ... Hi I'm trying to write a macro to search for something then move one rwo and then delete two rows. I can do the search and the delete but I cannot do the move and the selecting of two rows! Any ideas please but I lose any more sleep? Thanks MB |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK, this is what I have so far (and I've only got this far by Recording a
macro...) Range("A1").Select Cells.Find(What:="No History", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Rows("4:5").Select Selection.Delete Shift:=xlUp Its the "Rows("4:5").Select that I need to automate as it won't always be rows 4 and 5 Thanks "Tom Ogilvy" wrote: Post your code so we have some idea of what technique you are using to search and so forth. -- regards, Tom Ogilvy "Pugwyrm" wrote in message ... Hi I'm trying to write a macro to search for something then move one rwo and then delete two rows. I can do the search and the delete but I cannot do the move and the selecting of two rows! Any ideas please but I lose any more sleep? Thanks MB |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim rng as Range
Range("A1").Select set rng =Cells.Find(What:="No History", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) if not rng is nothing then rng.offset(2,0).Resize(2).EntireRow.Delete End If if there will be multiple occurances of "No History" Dim rng as Range Range("A1").Select set rng =Cells.Find(What:="No History", _ After:=Range("A65536"), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) if not rng is nothing then frow = rng.row do rng.offset(2,0).Resize(2).EntireRow.Delete set rng = cell.findnext(rng) Loop while rng.row fRow End If "Pugwyrm" wrote in message ... OK, this is what I have so far (and I've only got this far by Recording a macro...) Range("A1").Select Cells.Find(What:="No History", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Rows("4:5").Select Selection.Delete Shift:=xlUp Its the "Rows("4:5").Select that I need to automate as it won't always be rows 4 and 5 Thanks "Tom Ogilvy" wrote: Post your code so we have some idea of what technique you are using to search and so forth. -- regards, Tom Ogilvy "Pugwyrm" wrote in message ... Hi I'm trying to write a macro to search for something then move one rwo and then delete two rows. I can do the search and the delete but I cannot do the move and the selecting of two rows! Any ideas please but I lose any more sleep? Thanks MB |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Cheers, it's a start!
"Tom Ogilvy" wrote: Dim rng as Range Range("A1").Select set rng =Cells.Find(What:="No History", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) if not rng is nothing then rng.offset(2,0).Resize(2).EntireRow.Delete End If if there will be multiple occurances of "No History" Dim rng as Range Range("A1").Select set rng =Cells.Find(What:="No History", _ After:=Range("A65536"), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) if not rng is nothing then frow = rng.row do rng.offset(2,0).Resize(2).EntireRow.Delete set rng = cell.findnext(rng) Loop while rng.row fRow End If "Pugwyrm" wrote in message ... OK, this is what I have so far (and I've only got this far by Recording a macro...) Range("A1").Select Cells.Find(What:="No History", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Rows("4:5").Select Selection.Delete Shift:=xlUp Its the "Rows("4:5").Select that I need to automate as it won't always be rows 4 and 5 Thanks "Tom Ogilvy" wrote: Post your code so we have some idea of what technique you are using to search and so forth. -- regards, Tom Ogilvy "Pugwyrm" wrote in message ... Hi I'm trying to write a macro to search for something then move one rwo and then delete two rows. I can do the search and the delete but I cannot do the move and the selecting of two rows! Any ideas please but I lose any more sleep? Thanks MB |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Destroy command button with a Macro? | Excel Discussion (Misc queries) | |||
Create a search Field within a worksheet to search command buttons | Excel Programming | |||
How to make VBA code to self-destroy itself? | Excel Programming | |||
Inserting lines that don't destroy macros | Excel Programming | |||
Seek and destroy | Excel Programming |