Skip i'r prif gynnwys

Sut i dynnu sylw at gell weithredol neu ddethol yn Excel?

Os oes gennych daflen waith fawr, efallai ei bod yn anodd ichi ddarganfod cipolwg ar y gell weithredol neu'r detholiad gweithredol. Ond, os oes gan y gell / adran weithredol liw rhagorol, i ddarganfod ni fydd yn broblem. Yn yr erthygl hon, byddaf yn siarad am sut i dynnu sylw awtomatig at y gell weithredol neu'r ystod ddethol o gelloedd yn Excel.

Tynnwch sylw at gell weithredol neu ddetholiad gyda chod VBA


swigen dde glas saeth Tynnwch sylw at gell weithredol neu ddetholiad gyda chod VBA

Gall y cod VBA canlynol eich helpu i dynnu sylw at y gell weithredol neu ddetholiad yn ddeinamig, gwnewch fel a ganlyn:

1. Daliwch i lawr y ALT + F11 allweddi i agor y Ffenestr Microsoft Visual Basic for Applications.

2. Yna dewiswch Llyfr Gwaith hwn o'r chwith Archwiliwr Prosiect, cliciwch ddwywaith arno i agor y Modiwlau, ac yna copïo a gludo gan ddilyn y cod VBA i'r Modiwl gwag:

Cod VBA: Tynnu sylw at gell neu ddetholiad gweithredol

Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
'Update 20140923
Static xLastRng As Range
On Error Resume Next
Target.Interior.ColorIndex = 6
xLastRng.Interior.ColorIndex = xlColorIndexNone
Set xLastRng = Target
End Sub

doc-uchafbwynt-gweithredol-cell-1

3. Yna arbedwch a chau'r cod hwn, ac ewch yn ôl i'r daflen waith, nawr, pan fyddwch chi'n dewis cell neu ddetholiad, bydd y celloedd a ddewiswyd yn cael eu hamlygu, a bydd yn cael ei symud yn ddeinamig wrth i'r celloedd a ddewiswyd newid.

Nodiadau:

1. Os na allwch ddod o hyd i'r Pane Archwiliwr y Prosiect yn y ffenestr, gallwch glicio Gweld > Archwiliwr Prosiect yn y Ffenestr Microsoft Visual Basic for Applications i'w agor.

2. Yn y cod uchod, gallwch chi newid .ColorIndex = 6 lliw i liw arall yr ydych yn ei hoffi.

3. Gellir cymhwyso'r cod VBA hwn i bob taflen waith yn y llyfr gwaith.

4. Os oes rhai celloedd lliw yn eich taflen waith, collir y lliw pan gliciwch y gell ac yna symud i gell arall.


Erthygl gysylltiedig:

Sut i dynnu sylw awtomatig at res a cholofn cell weithredol yn Excel?

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I had the same problem, read the whole page and comments. While thinking to apply it or not, I was just randomly clicking on number and letters to select the whole column and rows. Then suddenly highlight of selected cell feature came back :)
This comment was minimized by the moderator on the site
Hello, if someone can help me... I pick up this code in internet (apologies to the owner). It does almost what i need but this code select the entirerow. What i need is a change that alow to select just the first two cells of the row of the activecells. When i click in the cell, i need that the cell of the column "$I16" and "$J16" (16 is the first line of my table) of that row became interior color (=9359529). The code is this: 
Dim lTarget As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Row >= 16 Then

If Not lTarget Is Nothing Then

lTarget.EntireRow.Interior.ColorIndex = 0
End If

Target.EntireRow.Interior.Color = 9359529

Set lTarget = Target
End If
End Sub

Can you help me? I had try to change this code but the only thing i can as the select the interior color of the cell target and not the column "$I" and "$J" in that specific row.Thank you for your help.
Luis Lopes
This comment was minimized by the moderator on the site
I know that you proposed a solution but the solution comes with another problem as you described below: "The only problem with having this code active is that you can no longer change the active cell color as it changes back to what it was before you clicked it. I suggest that if you need to change the highlight colors on the sheet, do so with macros disabled or change the sub name for a second so it doesn't trigger when you are clicking on cells". This is not an acceptable alternative for me. I need to be able to change the colors in the cells when the macro is active. Do you have a solution for this this problem. If you come up with a solution for this problem please republish your corrected macro the new macro in full (rather than proposing patches to your original macro because I am technically challenged as far as macro are concerned).
This comment was minimized by the moderator on the site
I tried your macro by copying and pasting it into my Excel file. I did change one thing in the macro though. I changed the color index from 6 to 24 (to a color different than the colors I am currently using in my macro). It worked very nicely and I liked it a lot but then started causing a problem for me. I have a lot of cells filled with with colors in my Excel. The macro started removing the color fill from every cell touched. I don't know how to stop the macro's this odd behavior. I did not have any choice but to remove the macro from my file. I still like to use this macro if someone can help me to fix it.
This comment was minimized by the moderator on the site
That was super helpful, thank you.
This comment was minimized by the moderator on the site
Anyway you can do the left adjacent cell to highlight instead of active cell? Or a range of cells around the activecell?
This comment was minimized by the moderator on the site
Thank you, but use this with caution. It has the undesirable counter effect of not letting undo. Is there any solution for that?
This comment was minimized by the moderator on the site
But i am unable to do undo option and lose the previously assigned cell color also.
Please provide solution
This comment was minimized by the moderator on the site
Perfect solution as I always tend to loose the track of the highlighted cell during "Find and Select" operation. Thanks a lot.
This comment was minimized by the moderator on the site
Great!! But what if I don't want to lose the previously assigned cell color? That would be greater to know.
This comment was minimized by the moderator on the site
Use a conditional format on the cells you want to protect.
This comment was minimized by the moderator on the site
Instead of "ColorIndex" which has a limited set of 255 values (meaning any custom colors are lost), use "Color" instead. You'll need to store the old value in a new static long variable and also generate the highlight color you want with the RGB function. The only problem with having this code active is that you can no longer change the active cell color as it changes back to what it was before you clicked it. I suggest that if you need to change the highlight colors on the sheet, do so with macros disabled or change the sub name for a second so it doesn't trigger when you are clicking on cells, then just rename it back to normal to "re-activate" it. Here is my code:

Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)

Static xLastRng As Range
Static xLastRngColor As Long

On Error Resume Next

xLastRng.Interior.Color = xLastRngColor
xLastRngColor = Target.Interior.Color
Target.Interior.Color = RGB(255, 255, 0) 'compose whatever highlight color you want with RGB values, I am using yellow here
Set xLastRng = Target

End Sub
This comment was minimized by the moderator on the site
work.... great...
This comment was minimized by the moderator on the site
Yes, I would like to know this as well. How would you keep the previously selected cells highlight for tracking purposes?
This comment was minimized by the moderator on the site
See my comment above.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations