Hi,
I want to write a macro that finds a range between two "find" terms, so I
can cut it from a sheet and post into another sheet.
So, I first want to find "Reconciliations" in column D. Then find "Account
Balance"in column D. I then want to cut the rows between these two rows and
paste into another sheet. I will then run the macro again to find the next
occurences. So, the first time "Reconciliations" might be in row 50 and
"Account Balance" in row 60, so I cut rows 50 to 60. Next time
"Reconciliations" is in row 100 and "Account Balance" in row 145, so I cut
rows 100 to 145.
Below is the macro I want to modify, so any help would be greatly appreciated.
Thanks for looking
Paul
Sub Pastedetails()
'
' Cutpaste Macro
' Macro recorded 22/11/2005 by IT Services
'
' Keyboard Shortcut: Ctrl+x
Dim rngFound As Range
Dim sStart As String
Dim sDestRange As String
Sheets("Posting").Activate
sStart = "D1"
sDestRange = "D1"
Range(sStart).Select
Set rngFound = Cells.Find(What:="Reconciliations", After:=ActiveCell,
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext)
I think this is where I would have to modify the macro to find "Account
Balance" and set the range to be cut.
Do While Not rngFound Is Nothing
If Not rngFound Is Nothing Then
Range(rngFound.Offset(0, 0).Address, rngFound.Offset(13,
0).Address).EntireRow.Cut
Sheets("Summary").Activate
ActiveCell.SpecialCells (xlCellTypeLastCell)
ActiveSheet.Paste
sDestRange = Range(sDestRange).End(xlDown).Offset(1, 0).Address
Cells.Select
Cells.EntireColumn.AutoFit
Sheet1.Activate
End If
Range(rngFound.Offset(1, 0).Address).Activate
Set rngFound = Cells.FindNext(After:=ActiveCell)
Windows("Control1.xls").Activate
ActiveCell.SpecialCells(xlCellTypeLastCell).Offset(1, -5).Select
Loop
End Sub
Bookmarks