Àx¦s¦U¨ú±oµJÂI«á¬Y¤@Äæ¦ìÅܦâ
- ©«¤l
- 154
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 200
- ÂI¦W
- 1
- §@·~¨t²Î
- windwos 7
- ³nÅ骩¥»
- 64bit
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2017-5-29
- ³Ì«áµn¿ý
- 2025-1-1
|
https://stackoverflow.com/questions/58282085/change-cell-color-when-it-selected-and-back-original-color-after-leaving-it
¼Ó¥DnªºÀ³¸Ó¬O³oÓ¥\¯à |
|
|
|
|
|
|
- ©«¤l
- 154
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 200
- ÂI¦W
- 1
- §@·~¨t²Î
- windwos 7
- ³nÅ骩¥»
- 64bit
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2017-5-29
- ³Ì«áµn¿ý
- 2025-1-1
|
¥»©«³Ì«á¥Ñ quickfixer ©ó 2024-2-2 07:56 ½s¿è
¦^´_ 9# quickfixer
¸Ó¦ì§@ªÌªºµ{¦¡½X¦³2Ó°ÝÃD
µ{¦¡°õ¦æ¤¤,µLªkקïÃC¦â
µ{¦¡¶}ÀY¥[¤Jif, cc ¬Ýn¤£n¥Î¬YÓcell¥N´À
cc = "ÃC¦â¥iקï"
If cc = "ÃC¦â¥iקï" Then Exit Sub
¿ï¨úÄæ¦ì·|§âµLÃöªº¦C¼Æ¥þ³¡©ñ¤J°}¦C,¤]¤£¯à¿ï¾ãÓ¤u§@ªí,µ{¦¡·|lag¶W¤[
²³æ¥[Ó¨î,¥i¿ï¨úªº¦C¤W100,Äæ¤W26,³on¬Ý¹q¸£®Ä¯àקï
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static rngcolor As Range
Static OldColor As Variant
Dim rw As Long, cl As Long
'cc = "ÃC¦â¥iקï"
If cc = "ÃC¦â¥iקï" Then Exit Sub
If Target.Columns.Count > 26 Then Exit Sub
If Not rngcolor Is Nothing Then
If IsArray(OldColor) Then
On Error GoTo NoRestore
For rw = 1 To rngcolor.Rows.Count
For cl = 1 To rngcolor.Columns.Count
If IsEmpty(OldColor(rw, cl)) Then
rngcolor.Cells(rw, cl).Interior.ColorIndex = xlNone
Else
rngcolor.Cells(rw, cl).Interior.Color = OldColor(rw, cl)
End If
Next
Next
On Error GoTo 0
Else
If IsEmpty(OldColor) Then
rngcolor.Interior.ColorIndex = xlNone
Else
rngcolor.Interior.Color = OldColor
End If
End If
End If
NoRestore:
On Error GoTo 0
If Target.Rows.Count > 100 Then nr = 100 Else nr = Target.Rows.Count
Set rngcolor = Target.Resize(nr)
ReDim OldColor(1 To nr, 1 To Target.Columns.Count)
For rw = 1 To nr
For cl = 1 To Target.Columns.Count
If Target.Cells(rw, cl).Interior.ColorIndex = xlNone Then
OldColor(rw, cl) = Empty
Else
OldColor(rw, cl) = Target.Cells(rw, cl).Interior.Color
End If
Next
Next
rngcolor.Interior.Color = vbYellow
End Sub |
|
|
|
|
|
|
- ©«¤l
- 154
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 200
- ÂI¦W
- 1
- §@·~¨t²Î
- windwos 7
- ³nÅ骩¥»
- 64bit
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2017-5-29
- ³Ì«áµn¿ý
- 2025-1-1
|
¥»©«³Ì«á¥Ñ quickfixer ©ó 2024-2-2 08:23 ½s¿è
¦^´_ 12# coafort
Option Explicit ¨º¦æ§R±¼©Î¬O¥[¤W dim cc as string,nr as integer |
|
|
|
|
|
|