設萬維讀者為首頁 廣告服務 聯繫我們 關於萬維
簡體 繁體 手機版
分類廣告
版主:
萬維讀者網 > 靈機一動 > 帖子
零加一中:Excel問題解答
送交者: 俠行天涯 2009年04月12日10:09:44 於 [靈機一動] 發送悄悄話
Search "Excel Event Handler" in Google. There is a article giving detailed solution. -------------------------------------------------------------- An event handler is associated with just a single worksheet. Start from that worksheet and hit alt-F11 to open the VB editor. In the upper left window (Project - VBA Project) double click the name of your worksheet. In the right pane, click the left drop down and change general to Worksheet. In the right drop down, pick Change. This will cause Excel to pre-enter the following macro shell for you: Private Sub Worksheet_Change(ByVal Target As Range) UserInput = Target.Value If UserInput > 1 Then NewInput = Left(UserInput, Len(UserInput) - 2) & ":" & Right(UserInput, 2) Application.EnableEvents = False Target = NewInput Application.EnableEvents = True End If End Sub Any time a cell is changed, the cell that was changed is passed to this program in the variable called "Target". When someone enters a time with a colon in the worksheet, it will evaluate to a number less than one. The If block makes sure to only change cells if they are greater than one. I use the left() and right() functions to break the user input into hours and minutes and insert a colon in between. Whenever the user enters "2345", the program will change this entry to 23:45.
0%(0)
0%(0)
標 題 (必選項):
內 容 (選填項):
實用資訊
回國機票$360起 | 商務艙省$200 | 全球最佳航空公司出爐:海航獲五星
海外華人福利!在線看陳建斌《三叉戟》熱血歸回 豪情築夢 高清免費看 無地區限制
一周點擊熱帖 更多>>
一周回復熱帖
歷史上的今天:回復熱帖
2008: 簡單球面幾何問題解
2008: 解救美麗的公主的難題
2007: 高科技公司面試 q No.1解
2006: 童年回憶(礦石收音機)