Copying to cell A1 - Invalid Compiler Error

izzyq

New Member
Joined
Mar 24, 2002
Messages
20
I have a peice of code that allows me to copy a range of A29:T53 from an excel file to a cell A1 of a new excel sheet. It continues to give me an Invalid Qualifier Error at the "copy cell values" action.

Here is the code and the error: The invalid qualifier is in red

Option Explicit

Sub Folder_Workbooks()

Dim wkbCopy As Excel.Workbook
Dim Path$, Workbook$, RangeCopy$
Dim Sheet%

Application.DisplayAlerts = False
Application.EnableEvents = False

'set range address to copy from/to
RangeCopy$ = "K29:T53"
Path$ = "W:ComptrolCorp_RepMONTHEND2002Monthly StewardshipOPEX"
Workbook$ = Dir(Path$ & "*01*.xls")

'loop all workbooks in folder
Do While Not Workbook$ = ""

'assign sheet index to copy data to
Sheet% = Sheet% + 1

'open workbook to copy from
Set wkbCopy = GetObject(Path$ & Workbook$)

'copy cell values
ThisWorkbook.Sheets(Sheet%).Range(Cells(1), _
Cells(RangeCopy$.Rows.Count, RangeCopy$.Columns.Count)) _
= wkbCopy.Sheets(1).Range(RangeCopy$).Value

wkbCopy.Close
Set wkbCopy = Nothing

'try to find next workbook in folder
Workbook$ = Dir
Loop

Application.EnableEvents = True
Application.DisplayAlerts = True


End Sub

Any help would be appreciated. Thanks

_________________
Help Me Obi Wan Kenobi, You're My Only Hope.
This message was edited by izzyq on 2002-03-26 08:05
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Sorry. I'm not Obi wan, but try this.
Regards,

Sub Folder_Workbooks() 'ReconstructionByColo
Dim wkbCopy As Workbook, path$, Workbook$, RangeCopy$, Sheet%
With Application
.DisplayAlerts = False
.EnableEvents = False
RangeCopy$ = "K29:T53"
'Ithink Need "/"
path$ = "W:ComptrolCorp_RepMONTHEND2002Monthly StewardshipOPEX/"
Workbook$ = Dir(path$ & "*01*.xls")
Do While Not Workbook$ = ""
Sheet% = Sheet% + 1
Set wkbCopy = GetObject(path$ & Workbook$)
'necessary to clarify which sheet is referred to
With wkbCopy.Sheets(1).Range(RangeCopy$)
ThisWorkbook.Sheets(Sheet%).Cells(1, 1) _
.Resize(.Rows.Count, .Columns.Count).Value = .Resize.Value
End With
wkbCopy.Close
Set wkbCopy = Nothing
Workbook$ = Dir
Loop
.EnableEvents = True
.DisplayAlerts = True
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top