【发布时间】:2020-02-18 21:55:29
【问题描述】:
Dim ar as variable
Sheets("Sheet1").Range("A4").Resize(UBound(ar) + 1) =
Application.Transpose(ar)
除了粘贴格式外,它工作得很好。我的列表中有奇怪的数字,它应该作为文本粘贴,因为 excel 会将这些数字转换为日期或不同的值。
如何在 Application.Transpose 中添加以下内容? .PasteSpecial xlPasteValues
Edit2:下面的代码应该对 sheet2 的 B 列中的值进行排序,并将它们转置到 Sheet1 中。但是,它不会转置值。我做错了什么?
Private Sub Workbook_Open()
ThisWorkbook.RefreshAll
DoEvents
Dim r As Range
Dim rng As Range
Dim ar As Variant
Dim var As Variant
With Sheets("Sheet2").Range("B2").CurrentRegion
With CreateObject("scripting.dictionary")
For Each rng In Range("B3", Range("B" & Rows.Count).End(xlUp))
var = .Item(rng.Value)
Next
ar = .Keys
End With
End With
With Sheets("Sheet1").Range("A4").Resize(UBound(ar) + 1)
.NumberFormat = "@"
.Value = Application.Transpose(ar)
End With
【问题讨论】:
-
既然您已经发布了其他代码,请参阅我的编辑回答,了解您的代码出了什么问题,以及建议的解决方案。