LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Loop not returning to original workbook

This macro works to a point. It's suppose to open up another workbook,
then come back, and perform a Do Until, looking for records that are
over 360 days old, copy that record over to the other workbook, then
come back and loop to read the next record.

It performs OK for the 1st record to be copied, but it won't come back
to the original workbook, (which has a name that changes each day,
based on the date.)

If you have any suggestions... please let me know. Thanks, J.O.

Sub OlderThanYearList()
'This will go through the list, and find all those records that are
older
'than a year. It will copy those records to the Year Old List file.

'Opens up the Year Old file
Workbooks.Open Filename:= _
"\\ceddfssrv01\cedroot\public\Furniture Staging List\Year old
list - Current Year.xls"

'Returns to Staging List (can't use the file name, since the name
changes each day based on date)
ActiveWindow.ActivatePrevious
With Sheets("Official List")
.Select
.Range("Date_Staged").Select
End With

Do Until IsEmpty(ActiveCell.Value)

ActiveCell.Offset(1, 0).Select 'goes down to the next cell.
If Range("Current_Date").Value - ActiveCell.Value 360 Then
Rows(ActiveCell.Row).Select
Selection.Copy

'Switches to the Year Old file to paste
Workbooks("Year old list - Current Year.xls").Activate
Sheets("Imports").Select
Range("B65536").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste

'It should go back to the original file, and to the previous active
cell just copied from. Again, I can't use the workbook name because
that name will change each day.
ActiveWindow.ActivatePrevious 'I tried putting this line after End
IF, but it didn't work at all.

End If

Loop
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning to original view. Gazz_85[_2_] Excel Discussion (Misc queries) 4 July 7th 09 01:06 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Trouble returning to original active cell Giznawz Excel Programming 3 October 3rd 05 01:52 PM
Trouble turning off sheet updating and returning to original active cell Giznawz Excel Programming 1 October 1st 05 10:24 PM
Returning to original workbook Jim Cone Excel Programming 0 July 23rd 04 11:03 AM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"