Excel VBA是個好東西 最近總要和許多 500 甚至有 5000 多條數據的excel表格打交道,感覺如果不學點VBA知識,自己寫個程式,解決點問題是要在重複得查找工作中累死的。當年程式設計課明白計算西裝機就是用來搞定重複的事情的,於是今天搞了本EXCEL VBA寶典。學了一個晚上,寫了段迴圈,解決的我周五沒搞定的工作,開心,貼個Source Code紀念一下, 歡迎指正!Sub Macro41()'' 信用貸款Macro41 Macro' Macro recorded 2008/4/10 by ftpe501'Dim PT, f_cell, f_range As RangeSet w2 = Sheets("table_all")Set f_range = w2.Columns("B")Set PT = 室內裝潢ActiveSheet.Range("d2")Do Until PT.Value = EmptySelect Case PT Case Is > 70000siteid = PT Case Is > 60000siteid = 10000 + PT Case Is > 30000siteid = PT - 20000Case Is 房屋買賣> 20000siteid = PT - 10000Case Elsesiteid = PT End SelectRange(PT.Offset(, 3), PT.Offset(, 5)).ClearContentsSet f_cell = f_range.Find(siteid)If Not f_cell Is Nothing 票貼ThenPT.Offset(, 5) = "Found"PT.Offset(, 3) = w2.Cells(f_cell.Row, 4)PT.Offset(, 4) = w2.Cells(f_cell.Row, 5)End IfSet PT = PT.Offset(1, 西裝0)LoopColumns("G:H").SelectSelection.NumberFormat = "0.000000"Columns("I:I").SelectWith Selection.HorizontalAlignment = xlRight' .VerticalAlignment = xlCenterEnd 買屋網With'End Sub' If x.Value = y.Value Then y.Offset(0, 2).Copy x.Offset(0, 2)想學excel和VBA的這邊 算是目前國內一流的討論區 商務中心http://gb.twbts.com/index.php?PHPSESSID=2f5aa41f2dc4af440aeea3ca927d7aa5&board=3.0 http://0rz.net Excel VBA 巨集做什麼用? 應該有不少人偶爾.常常.甚至每天...都需要在使用Excel的時有巢氏房屋候重複地執行某些動作像是例如我每天都會接受到某人給我的.xls檔案 , 但是我必須刪除其中的幾個欄位然後整理一下 , 再加上一些公式 , 這樣的檔案才符合我的需要這時候巨集就派上用場了 建立花蓮民宿第一個Excel巨集 按這裡不知道如何寫巨集的時候 , "錄製" 是學習巨集的好方法  , 可以設定巨集的名稱 , 先使用預設值就可以了....按下確定
arrow
arrow
    全站熱搜

    am04amgtey 發表在 痞客邦 留言(0) 人氣()