Pasting to A1

izzyq

New Member
Joined
Mar 24, 2002
Messages
20
I have this code which copies the range K20:T50 from 10 XL files and pastes them to an new work book. Currently it will paste the copied data to K20:T50 in the new sheets and I need it start copying at A1.

The code I have right keeps giving me an "invalid qualifier error" for the "RangeCopy$" variable. The pertinent code is under the "Copy Cell Values" tag.



Sub Folder_WorkbooksCopy()
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(RangeCopy$).Value = _
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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try just changing this code:

<pre>
'set range address to copy from/to
RangeCopy$ = "K29:T53"
</pre>

To

<pre>
'set range address to copy from/to
RangeCopy$ = "A1"</pre>

HTH
 
Upvote 0
Changing this code changes the information that is initially copied. Instead of copying the deired K29:T53, it will only copy cell A1. It will copy it to A1 but it is not the correct information.
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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