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
精彩评论