代码如下。详见附件
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing And Target.Count = 1 Then
Dim N&
N = Val(Target)
If N > 0 And N <= Cells.Columns.Count Then
Sheet1.Columns(N).Copy [A1]
Else
Columns(1).ClearContents
End If
End If
End Sub
sub a()
sheets("sheet1").columns([a1]).copy [a1]
end sub
代码放在SHEET2中。
你应该判断你输入的数值等于列数,然后在进行复制的代码就可以了