创建新工作表和复制数据

时间:2016-03-30 07:56:08

标签: excel excel-vba vba

我有下面的代码,它将创建一个关于选择A2的新工作表,但工作正常,但我也想做的是复制第2行中的数据并将其复制到新工作表中。除此之外,如果我点击A3创建另一个工作表,我想将第3行中的数据复制到该工作表,依此类推。

任何想法??

Private Sub Worksheet_SelectionChange()

Dim cTab As Integer
cTab = ActiveCell.Row - 1


    If Selection.Count = 1 Then

        If Not Intersect(Target, Range("A2:A201")) Is Nothing Then

            Dim WS1 As Worksheet
            On Error Resume Next
            Set WS1 = Worksheets(cTab & ".")

            If WS1 Is Nothing Then

                Application.ScreenUpdating = False
                ActiveCell = cTab & "."
                    Sheets("Template").Visible = True
                Sheets("Template").Select
                Sheets("Template").Copy After:=Sheets(Worksheets.Count)
                ActiveSheet.Name = cTab & "."
                'Sheets("Template").Visible = False
                Application.ScreenUpdating = True

                Else

                Sheets(cTab & ".").Select

            End If
        End If
    End If

End Sub

1 个答案:

答案 0 :(得分:0)

您可以将代码修改为类似下面的代码,它应该按照您的描述复制行。

Curl error: Couldn't resolve host 'bus.go.kr'
--------------------
Array
(
[url] => http://bus.go.kr/getSubway_6.jsp?statnId=1003000323&subwayId=1003
[content_type] => 
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
    (
    )

)

--------------------