LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default almost got it, but need help- pulling data from other workbooks

I have about 300 workbooks (different users, all in the same network
directory) and now I need to pull data out of the same worksheet for each
user- into one workbook so I can run some statistics on all the data
combined.

For testing purposes, my code is below, but I'm having trouble getting it to
paste (then close) properly.

Info: Win2000, Excel 2003
Each workbook's data sheet is protected, so I need to unprotect it (to copy)
then reprotect it before exiting
Each workbook has an onopen even that links it to a third workbook to upload
the most current source data for some worksheets in the workbook
Each workbook's before_close event includes code that saves the workbook as
part of the close (no warnings or pop-ups)

Once I get this working for one workbook, it should be easy to modify the
code to loop through each workbook in the target network directory.

Thanks for helping,
Keith


Sub GrabMyData()

Dim Owkbk As Workbook
Set Owkbk = ActiveWorkbook

Dim wkbk As Excel.Workbook

On Error Resume Next
Set wkbk = Workbooks.Open(\\mynetworkpath\ & "filename" & ".xls", 0,
True)
On Error GoTo 0

wkbk.Activate
'wkbk.Sheet1.Unprotect
wkbk.Sheets("Data Entry").Unprotect
wkbk.Sheets("Data Entry").Activate
LastRow = wkbk.Sheets("Data Entry").Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
wkbk.ActiveSheet.Range("A13:Z" & Trim(Str(LastRow))).Select
Selection.Copy
Application.CutCopyMode = False

Owkbk.Activate
Owkbk.Sheets("Sheet1").Range("A1").Select
Owkbk.ActiveSheet.Paste ' ******* it doesn't like this line *******

wkbk.Activate
wkbk.Sheet1.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
wkbk.Sheet1.EnableSelection = xlNoSelection
wkbk.Close (False)

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
Pulling/Collating Data from Workbooks chrisk Excel Worksheet Functions 6 April 21st 10 05:27 PM
Pulling Data from other excel workbooks? Frustrated Excel Discussion (Misc queries) 5 November 9th 09 07:19 PM
pulling data from multiple workbooks James Excel Discussion (Misc queries) 3 September 18th 08 05:29 PM
VBA pulling data from other workbooks? ph8[_32_] Excel Programming 2 February 24th 06 04:30 PM
Saving worksheet as CSV after pulling data from an external data source Richard Edwards[_3_] Excel Programming 4 February 25th 05 09:08 PM


All times are GMT +1. The time now is 09:22 AM.

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

About Us

"It's about Microsoft Excel"