Re: [算表] Excel:如何選取一個單元格後 整行底色變色(VBA)

看板Office作者 (windknife18)時間17年前 (2009/03/24 21:50), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串3/3 (看更多)
將以下加到: ThisWorkbook 的右邊程式區,即可解決存檔的問題... Dim Pre_Row As Integer Dim Pre_color As Integer Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If (Pre_Row > 0) Then If (Rows(Pre_Row).Interior.ColorIndex = 35) Then Rows(Pre_Row).Interior.ColorIndex = Pre_color End If End If End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) If (Pre_Row > 0) Then If (Rows(Pre_Row).Interior.ColorIndex = 35) Then Rows(Pre_Row).Interior.ColorIndex = Pre_color End If End If x = ActiveCell.Row Pre_Row = x If IsNull(Rows(x).Interior.ColorIndex) Then Pre_color = 0 Else Pre_color = Rows(x).Interior.ColorIndex End If Rows(x).Interior.ColorIndex = 35 End Sub -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.87.154

03/24 22:11, , 1F
對了原本 sheet1 的程式請清空
03/24 22:11, 1F

03/24 22:54, , 2F
推~ 直接還原顏色就不用擔心號碼要存哪了 ^^
03/24 22:54, 2F
文章代碼(AID): #19oEKa7k (Office)
文章代碼(AID): #19oEKa7k (Office)