用Excel巧轉工資條_第1頁
用Excel巧轉工資條_第2頁
用Excel巧轉工資條_第3頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、用Excel巧轉工資條Excel具有強大的數據處理和打印輸出功能,并且易學易用,是廣大用戶喜歡使用的電子表格處理軟件。現在一些單位的財會人員喜歡用Excel打印本單位的職工工資總表與工資條,但在Excel中要將工資總表(手工地轉換為工資條則是一件比較煩瑣的事,下面是我編寫的一個Excel宏,運行這個宏就可將編輯好了的工資總表很方便地轉換為工資條打印輸出。 在Excel中新建一個文件,將其命名為“工資表與工資條”,在工作表“sheet1”中輸入并編輯好本單位職工工資總表(后,點擊“工具”菜單“宏”“宏”輸入宏名“生成工資條”創建,輸入如下的宏的各行文本,輸入完成后保存該宏。將工作表“sheet1

2、”復制為另一個工作表“sheet2”中,使“sheet2”成為當前工作表,執行剛才創建的宏,即可很快將表1所示的工資表轉換為表2所示的工資條。 宏的內容如下: Sub生成工資條() Cells.Select '選擇整個表去掉表格線 Range("F1").Activate Selection.Borders(xlDiagonalDown).Line Style=xlNone Selection.Borders(xlDiagonalUp).LineStyle=xlNone Selection.Borders(xlEdgeLeft).LineStyle=xlNone S

3、election.Borders(xlEdgeTop).LineStyle=xlNone Selection.Borders(xlEdgeBottom).LineStyle=xlNone Selection.Borders(xlEdgeRight).LineStyle=xlNone Selection.Borders(xlInsideVertical).LineStyle=xlNone Selection.Borders(xlInsideHorizontal).LineStyle=xlNone Rows("2:2").Select '選擇第2行 Selection.

4、InsertShift:=xlDown '在第2行前插入一行,保持第2行 為選中狀態 num=150 '總人數×3,如工資表中有100人則 為100×3即num=300 col=14 '工資表的欄數,如工資表有17欄則 'col=17 num1=4 DoWhilenum1<=num '循環插入空行 Range(Cells(num1,1),Cells(num1,col).Select '選中第num1行的第1列到第col列 Selection.InsertShift:=xlDown Selection.InsertShif

5、t:=xlDown num1=num1+3 Loop Range(Cells(1,1),Cells(1,col).Select Application.CutCopyMode=False '剪切復制模式無效 Selection.Copy '復制選擇區域 Range("A2").Select '選擇A2單元格 ActiveSheet.Paste '從A2單元格起粘貼內容 num2=5 DoWhilenum2<=num '循環插入標題行 Range(Cells(1,1),Cells(1,col).Select Application

6、.CutCopyMode=False Selection.Copy Cells(num2,1).Select ActiveSheet.Paste num2=num2+3 Loop Range(Cells(2,1),Cells(3,col).Select Application.CutCopyMode=False Selection.Borders(xlDiagonalDown).LineStyle =xlNone '定義表格邊框線、內線樣式 Selection.Borders(xlDiagonalUp).LineStyle=xlNone WithSelection.Borders(xl

7、EdgeLeft) .LineStyle=xlDouble .Weight=xlThick .ColorIndex=xlAutomatic EndWith WithSelection.Borders(xlEdgeTop) .LineStyle=xlDouble .Weight=xlThick .ColorIndex=xlAutomatic EndWith WithSelection.Borders(xlEdgeBottom) .LineStyle=xlDouble .Weight=xlThick .ColorIndex=xlAutomatic EndWith WithSelection.Bor

8、ders(xlEdgeRight) .LineStyle=xlDouble .Weight=xlThick .ColorIndex=xlAutomatic EndWith WithSelection.Borders(xlInsideVertical) .LineStyle=xlDash .Weight=xlThin .ColorIndex=xlAutomatic EndWith WithSelection.Borders(xlInsideHorizontal) .LineStyle=xlDash .Weight=xlThin .ColorIndex=xlAutomatic EndWith Se

9、lection.Copy Range(Cells(5,1),Cells(6,col).Select Selection.PasteSpecialPaste:=xlFormats,Operation:=xlNone,SkipBlanks:=_ False,Transpose:=False '接上行刪除上行尾的連字符 _,復制表格線樣式 num3=8 DoWhilenum3=num '循環復制表格線樣式 Range(Cells(num3,1),Cells(num3+1,col) .Select Selection.PasteSpecialPaste:=xlFormats,Operation:=xlNone,SkipBlanks:=_ False,Transpose:=False num3=num3+3 Loop Rows("1:1").Sele

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論