【发布时间】:2018-11-03 23:42:52
【问题描述】:
我是 VBA 新手...尝试按名称搜索特定列并将它们粘贴到新工作表中。
到目前为止,我所拥有的内容似乎很笨重,并且没有复制或粘贴所需的列,而是我目前在剪贴板上拥有的内容!
理想情况下,我可以搜索 3 个不同的列并将它们粘贴到新工作表上。
任何帮助将不胜感激
Dim CheckText As String
Dim CheckRow As Long
Dim FindText As Range
Dim CopyColumn As String
CheckText = “Bsp” 'Bsp is an example header
CheckRow = 1 'Row with desired header
Dim oldsheet As Worksheet
Set oldsheet = ActiveSheet
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Pivot"
oldsheet.Activate
ActiveSheet.Select
'trying here to create a new sheet, name it and go back to the first sheet
Set FindText = Rows(CheckRow).Find(CheckText)
If FindText Is Nothing Then
MsgBox "Bsp not found"
End If
CopyColumn = Cells(CheckRow, FindText.Column).Column
Columns(CopyColumn).Select.Copy
Sheets("Pivot").Select
ActiveSheet.Paste
【问题讨论】:
标签: excel vba copy copy-paste paste