Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Compile error

I'm wanting to Copy some auto-filtered data to
worksheets("POReqsSent") and to
worksheets("POReqsHistoy") << of the same current Workbook
PLUS I ant to copy it to a Closed Workbook
on the same drive
workbbook("POs-ExecDir.xls").Worksheets("POReqsIncoming").Range(" A2")

Right now my code referring to the closed workbook is (above mention and
below stated Is BOMBING!!
Can some one assist?


.... Code before...
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No Data found to copy"
Exit Sub
Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:="\\MyPc1\Shareddocs\\POs-ExecDir.xls\Worksheets("POReqsIncoming").Range("A2 ")"
End If
rng2.EntireRow.Delete
.... code following...






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Compile error

You can't copy to a closed workbook. You basically can't write to a closed
workbook unless you want to treat it as a database and use something like
ADO to update the "table"

Easiest is just to open it, write to it, save it, close it.

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:OTD%e.125174$Ep.101153@lakeread02...
I'm wanting to Copy some auto-filtered data to
worksheets("POReqsSent") and to
worksheets("POReqsHistoy") << of the same current Workbook
PLUS I ant to copy it to a Closed Workbook
on the same drive
workbbook("POs-ExecDir.xls").Worksheets("POReqsIncoming").Range(" A2")

Right now my code referring to the closed workbook is (above mention and
below stated Is BOMBING!!
Can some one assist?


... Code before...
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No Data found to copy"
Exit Sub
Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _

Destination:="\\MyPc1\Shareddocs\\POs-ExecDir.xls\Worksheets("POReqsIncoming
").Range("A2")"
End If
rng2.EntireRow.Delete
... code following...








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Compile error

Tom:
As you suggested I've tried to Open, Write, Save and Close the ExecWB
But I've still got a problem.. Can you see it?
Tks,
Jim

Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
<<<< Code is Bombing here !!! << No Clue Why!!
Destination:=ExecWB.sheets("Incoming").Close SaveChanges:=True
End If



"Tom Ogilvy" wrote in message
...
You can't copy to a closed workbook. You basically can't write to a
closed
workbook unless you want to treat it as a database and use something like
ADO to update the "table"

Easiest is just to open it, write to it, save it, close it.

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:OTD%e.125174$Ep.101153@lakeread02...
I'm wanting to Copy some auto-filtered data to
worksheets("POReqsSent") and to
worksheets("POReqsHistoy") << of the same current Workbook
PLUS I ant to copy it to a Closed Workbook
on the same drive
workbbook("POs-ExecDir.xls").Worksheets("POReqsIncoming").Range(" A2")

Right now my code referring to the closed workbook is (above mention and
below stated Is BOMBING!!
Can some one assist?


... Code before...
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No Data found to copy"
Exit Sub
Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _

Destination:="\\MyPc1\Shareddocs\\POs-ExecDir.xls\Worksheets("POReqsIncoming
").Range("A2")"
End If
rng2.EntireRow.Delete
... code following...










  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Compile error

ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")

should be

set ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")

rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=ExecWB.sheets("Incoming")

ExecWB.Close SaveChanges:=True


--
Regards,
Tom Ogilvy


"Jim May" wrote in message
news:3UI%e.125192$Ep.45754@lakeread02...
Tom:
As you suggested I've tried to Open, Write, Save and Close the ExecWB
But I've still got a problem.. Can you see it?
Tks,
Jim

Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
<<<< Code is Bombing here !!! << No Clue Why!!
Destination:=ExecWB.sheets("Incoming").Close SaveChanges:=True
End If



"Tom Ogilvy" wrote in message
...
You can't copy to a closed workbook. You basically can't write to a
closed
workbook unless you want to treat it as a database and use something

like
ADO to update the "table"

Easiest is just to open it, write to it, save it, close it.

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:OTD%e.125174$Ep.101153@lakeread02...
I'm wanting to Copy some auto-filtered data to
worksheets("POReqsSent") and to
worksheets("POReqsHistoy") << of the same current Workbook
PLUS I ant to copy it to a Closed Workbook
on the same drive
workbbook("POs-ExecDir.xls").Worksheets("POReqsIncoming").Range(" A2")

Right now my code referring to the closed workbook is (above mention

and
below stated Is BOMBING!!
Can some one assist?


... Code before...
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No Data found to copy"
Exit Sub
Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _


Destination:="\\MyPc1\Shareddocs\\POs-ExecDir.xls\Worksheets("POReqsIncoming
").Range("A2")"
End If
rng2.EntireRow.Delete
... code following...












  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Compile error

I got it going AND/PLUS learned
an important lesson I should have
already known; but anyway,
Thanks for your patience and continued
Contribution to this group;
Jim


"Tom Ogilvy" wrote in message
...
ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")

should be

set ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")

rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=ExecWB.sheets("Incoming")

ExecWB.Close SaveChanges:=True


--
Regards,
Tom Ogilvy


"Jim May" wrote in message
news:3UI%e.125192$Ep.45754@lakeread02...
Tom:
As you suggested I've tried to Open, Write, Save and Close the ExecWB
But I've still got a problem.. Can you see it?
Tks,
Jim

Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
ExecWB = Workbooks.Open("C:\Documents and Settings\Jim May\My
Documents\Art_Museum\Pos-ExecDir.xls")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
<<<< Code is Bombing here !!! << No Clue Why!!
Destination:=ExecWB.sheets("Incoming").Close SaveChanges:=True
End If



"Tom Ogilvy" wrote in message
...
You can't copy to a closed workbook. You basically can't write to a
closed
workbook unless you want to treat it as a database and use something

like
ADO to update the "table"

Easiest is just to open it, write to it, save it, close it.

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:OTD%e.125174$Ep.101153@lakeread02...
I'm wanting to Copy some auto-filtered data to
worksheets("POReqsSent") and to
worksheets("POReqsHistoy") << of the same current Workbook
PLUS I ant to copy it to a Closed Workbook
on the same drive
workbbook("POs-ExecDir.xls").Worksheets("POReqsIncoming").Range(" A2")

Right now my code referring to the closed workbook is (above mention

and
below stated Is BOMBING!!
Can some one assist?


... Code before...
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No Data found to copy"
Exit Sub
Else
Set rng1 = ActiveSheet.AutoFilter.Range
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsSent").Range("A2")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _
Destination:=Worksheets("POReqsHistory").Range("A2 ")
rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1).Copy _


Destination:="\\MyPc1\Shareddocs\\POs-ExecDir.xls\Worksheets("POReqsIncoming
").Range("A2")"
End If
rng2.EntireRow.Delete
... code following...
















Reply
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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
Compile error in hidden module error Melissa Zebrowski Excel Programming 3 February 20th 04 01:29 PM


All times are GMT +1. The time now is 12:40 PM.

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"