1

如上所述,我有一些代码过去曾用于根据搜索某个标题来粘贴列,但我终其一生都无法弄清楚如何将其调整为插入而不是粘贴。

本质上,这将用于创建摘要表,列的大小将来可能会有所不同,因此我需要插入它们以避免覆盖来自工作簿中其他表的值。

几乎可以肯定有比调整以下更好的方法,但非常感谢任何帮助。

我已经复制了我基于下面的原始代码。

Sub CopyColumnByTitle()

Dim t As Range

'Find "Name" in Row 1
  With Sheets(2).Rows(1)
   Set t = .Find("SEX", lookat:=xlPart)
'If found, copy the column to Sheet 2, Column A
'If not found, present a message
 If Not t Is Nothing Then
    Columns(t.Column).EntireColumn.Copy _
      Destination:=Sheets(3).Range("A1")
   Else: MsgBox "Title Not Found"
 End If
 End With
 End Sub

干杯

4

0 回答 0