|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 按钮2_Click()
-
- Dim vReadData1 As Variant
- Dim vReadData2 As Variant
- Dim vReadData3 As Variant
- Dim vReadData4 As Variant
- Dim vReadData5 As Variant
- Dim wWB As Workbook
- Dim nCol As Integer
- Dim sPath As String
-
- Dim sFile As String
- Dim B As String
- Dim vFill As Variant
- Dim nRow As Double
-
- Dim i%, r%, j%, c As Range
-
- Application.ScreenUpdating = False
- Range("a2:e70").ClearContents
-
- Set wWB = ThisWorkbook
- sPath = wWB.Path & ""
- sFile = Dir(sPath & "*.xls*")
- Do While sFile <> ""
- If sFile <> ThisWorkbook.Name Then
- With Workbooks.Open(sPath & sFile)
- vReadData1 = .Sheets("Sheet").UsedRange.Value
- .Close False
- End With
- For nRow = 2 To UBound(vReadData1)
- '需在此处加入填报日期IF语句判断
- x = CDate(vReadData1(nRow, 3))
- If CDate(vReadData1(nRow, 3)) - (Date - 0.5) >= 0 Then
- r = Range("b65536").End(xlUp).Row + 1
- For nCol = 2 To 4
- i = nCol + 2
- Cells(r, nCol) = vReadData1(nRow, i)
- Next
- End If
- Next
- End If
- sFile = Dir
- Loop
- r = Range("b65536").End(xlUp).Row
- Range(Cells(r, 1), [a2]).Value = Date
- Range("a1:e100").Sort key1:=Range("b1"), order1:=xlAscending, Header:=xlYes
- Application.ScreenUpdating = False
- End Sub
复制代码 |
|