Attribute Vb_name ="Modules"DimInputdate as StringDimNewbook asWorkbookSubextract data ()DimWs asWorksheetDimDatestr as StringDimPhone as StringDimMoney as StringDimGoods as StringDimNewws asWorksheetDimMoneyint as Integerinputdate=InputBox("Please enter the export date")IfInputdate ="" Then EndDimName as Stringname=Format(Inputdate,"m-d")SetWS = Worksheets (1)SetNewbook =Workbooks.Addnewbook.SaveAs Filename:=name &". xlsx"'ThisWorkbook.Sheets.Add after:=worksheets (worksheets.count) ' Add a new sheet before the first worksheetSetNEWWS = Newbook. Worksheets (1) Newws. Cells (1,1) ="Mobile phone number"NEWWS. Cells (1,2) ="Amount"NEWWS. Cells (1,3) ="Product"NEWWS. Cells (1,4) ="Date"NEWWS. Range ("a1:a65536"). ColumnWidth = -NEWWS. Range ("b1:b65536"). ColumnWidth = -NEWWS. Range ("c1:c65536"). ColumnWidth = -NEWWS. Range ("d1:d65536"). ColumnWidth = -NEWWS. Range ("a1:a65536"). HorizontalAlignment =Excel.xlCenternewws.Range ("b1:b65536"). HorizontalAlignment =Excel.xlCenternewws.Range ("c1:c65536"). HorizontalAlignment =Excel.xlCenternewws.Range ("D1"). HorizontalAlignment =Excel.xlCenternewws.Range ("d2:d65536"). HorizontalAlignment =Excel.xlLeftnewws.Range ("a1:a65536"). NumberFormatLocal ="@"NEWWS. Range ("b1:b65536"). NumberFormatLocal ="@"NEWWS. Range ("c1:c65536"). NumberFormatLocal ="@"NEWWS. Range ("d1:d65536"). NumberFormatLocal ="@"DimN as IntegerDimM as IntegerN=2m=2 DoDatestr= ws. Cells (N,Ten)IfDatestr = Inputdate ThenPhone= ws. Cells (N, -) Money= ws. Cells (N,8) Goods= ws. Cells (N,7) Newws. Cells (M,1) =Phonemoney=Format$ (Money," Standard") Newws. Cells (M,2) =MONEYNEWWS. Cells (M,3) =GOODSNEWWS. Cells (M,4) =DATESTRM= m +1End IfN= n +1Loop Untiln = ws. UsedRange.Rows.Count +1End Sub
Excel VBA operation Copy copy operation