[VBA] 蘇巧巧's Question



  1. 下载vba文件

  2. 去到表2,点击黄色的按钮,以便清空表2

  3. 然后点击青色的按钮,以便从表1导入data

  4. 其他:此次用到的VBA代码

  5. Option Explicit
    
    Sub main()
        Dim cell As Range
        
        With Worksheets("1")
            .Activate
            .Range("A3").Activate
        End With
        
        Do While Len(ActiveCell.Value) > 0
            With Worksheets("2")
                Worksheets("template").Range("A1:J4").Copy .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
                Worksheets("1").Range(ActiveCell, ActiveCell.Offset(0, 9)).Copy .Cells(.Rows.Count, 1).End(xlUp).Offset(-1, 0)
                ActiveCell.Offset(1, 0).Activate
            End With
        Loop
        
        With Worksheets("2")
            .Columns(1).Cells.Replace what:="dummyValues", replacement:="", lookat:=xlWhole
            .Activate
        End With
        
        MsgBox ("Data is imported into Sheet [2] now")
            
    End Sub
    
    Sub clearWorksheets()
        With Worksheets("2")
            .Cells.ClearContents
            .Cells.ClearFormats
        End With
        
        MsgBox ("Sheet [2] is cleared now")
    End Sub
    
                



Source: ---


Disclaimer: The information in this webpage is shared by anonymous users from external online sources. We cannot guarantee its accuracy or truthfulness. Users should exercise caution and verify information independently.


© 2023 sunnypeaceisland.com