pastespecial

eran3185

Board Regular
Joined
Apr 28, 2007
Messages
142
hi
i have a macro that take some files and copy them into one sheet.
but i want to use pastespecial instead simple copy .
ie : in book2 , i can't see c3 .
HOW CAN I DO THIS THING ?

THIS IS MY CODE :

Sub filecopy()
Application.ScreenUpdating = False
aw = ActiveWorkbook.Name
directory = "c:\test"
ChDir directory
myfile = Dir(directory & "/*.xls")
Do Until myfile = ""
Workbooks.Open myfile
Sheets(1).Select
Windows(myfile).Activate

Range("a1:d100").Select
Selection.Copy
Workbooks(aw).Activate
Sheets(1).Select
[a65536].End(xlUp).Offset(1, 0).Select

ActiveSheet.Paste
Application.CutCopyMode = False


Workbooks(myfile).Close False
myfile = Dir
Loop
Application.ScreenUpdating = True
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This may do it for you:

Code:
    Range("a1:d100").Copy
    Workbooks(aw).Activate
    With Sheets(1)
        .Range("a65536").End(xlUp).Offset(1, 0).Select
        .Paste
        With .Cells
            .Copy
            .PasteSpecial Paste:=xlPasteValues
        End With
    End With

HTH,

Smitty
 
Upvote 0
problem

for some reason , it's not work
this macro use the simple copy-paste , not PasteSpecial

why ?
 
Upvote 0
Not tested, but does this work?
Code:
Workbooks(aw).Sheets(1).Range("a65536").End(xlUp).Offset(1, 0).Value =  Range("a1:d100").Value
 
Upvote 0
Actually, it won’t work cos you’re working with a multiple cell range, sorry.
 
Upvote 0
i think that the problem is that i have some files .
some of them are protected by a password.
but i dont know the password .
 
Upvote 0

Forum statistics

Threads
1,214,877
Messages
6,122,051
Members
449,064
Latest member
scottdog129

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