why*_*heq 2 excel vba excel-vba
我使用Excel 2010具有以下功能:
Private Function MakeAllSheetsValuesOnly(targetBookName As String)
If Excel.ActiveWorkbook.Name = Excel.ThisWorkbook.Name Then
Else
Excel.Workbooks(targetBookName).Activate
Dim mySheet
For Each mySheet In Excel.ActiveWorkbook.Sheets
With mySheet
With .Cells
.Copy
.PasteSpecial Excel.xlPasteValues
End With
.Select
.Range("A1").Select
End With
Excel.ActiveWindow.SmallScroll Down:=-200
Excel.Application.CutCopyMode = False
Next mySheet
End If
End Function 'MakeAllSheetsValuesOnly
Run Code Online (Sandbox Code Playgroud)
它工作但我宁愿不依赖剪贴板是否有另一种方法来制作所有工作表值?
刚刚找到了另一个我在另一个程序中使用的逻辑,它与本主题相关:
Dim rSource As Range
Dim rDest As Range
Set rSource = .Range("C5:BG" & .Range("B4").Value + 4)
Set rDest = mySummaryBook.Sheets("Data_Measures").Cells(Rows.Count, 4).End(xlUp)(2, 1)
With rSource
Set rDest = rDest.Resize(.Rows.Count, .Columns.Count)
End With
rDest.Value = rSource.Value
Set rSource = Nothing
Set rDest = Nothing
Run Code Online (Sandbox Code Playgroud)
Tim*_*ams 11
也许是这样的:
With mySheet.UsedRange
.Value = .Value
End With
Run Code Online (Sandbox Code Playgroud)