开发者

Macro to copy a worksheet and paste into a new file using paste special values

开发者 https://www.devze.com 2023-02-16 05:30 出处:网络
I have a macro and I want it to copy sheet 1 from file A, and paste it (using paste special values) into file B, and hide the macro button on the pasted sheet in file B? This is my starting point

I have a macro and I want it to copy sheet 1 from file A, and paste it (using paste special values) into file B, and hide the macro button on the pasted sheet in file B? This is my starting point

Private Sub Update_Click()

Sheets("开发者_StackOverflow中文版Dallas").Select
Sheets("Dallas").Copy

End Sub


If you are looking only to copy cell values and nothing else, a shortcut would be something like:

dim rgSource as range
dim rgTarget as range

set rgSource = ActiveSheet.UsedRange  ' cells containing values on src sheet
set rgTarget = Workbooks.Add.Worksheets(1).Cells(1,1) ' new range on target sheet
set rgTarget = rgTarget.Resize(rgSource.Rows.Count, rgSource.Columns.Count) ' same sz

rgTarget = rgSource.Value  ' copies values into the target range on the other sheet
0

精彩评论

暂无评论...
验证码 换一张
取 消