Re: [算表] Excel:如何選取一個單元格後 整行底色變色(VBA)
想說把那兩個和在一起,忘了一開始會有問題 ....
Dim Pre_Row As Integer
Dim Pre_color As Integer
Private Sub Worksheet_SelectionChange(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
※ 引述《windknife18 (windknife18)》之銘言:
: 試看看合不合適囉 ...
: Dim Pre_Row As Integer
: Dim Pre_color As Integer
: Private Sub Worksheet_SelectionChange(ByVal Target As Range)
: If (Pre_Row > 0) And (Rows(Pre_Row).Interior.ColorIndex = 35) Then
: Rows(Pre_Row).Interior.ColorIndex = Pre_color
: 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
: ※ 引述《ntnl (本號)》之銘言:
: : 軟體: Excel
: : 版本: 2003 SP3
: : 如何可以選取某一儲存格(cell)後,橫向的整行變顏色?
: : 我原本上網找了一個VBA如下:
: : Private Sub Worksheet_SelectionChange(ByVal Target As Range)
: : Rows().Interior.ColorIndex = 0
: : x = ActiveCell.Row
: : Rows(x).Interior.ColorIndex = 35
: : End Sub
: : 但有一個問題
: : 我無法再使用變更底色的功能了
: : (選取第n行→變更底色為紅色→跳離第n行後,第n行又變回白色底色)
: : 請問如何改變呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.131.84.79
推
03/24 20:07, , 1F
03/24 20:07, 1F
→
03/24 20:09, , 2F
03/24 20:09, 2F
→
03/24 20:11, , 3F
03/24 20:11, 3F
推
03/24 20:22, , 4F
03/24 20:22, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
Office 近期熱門文章
PTT數位生活區 即時熱門文章