Skip i'r prif gynnwys

Sut i newid lliw celloedd pan fydd cell yn cael ei chlicio neu ei dewis yn Excel?

Bydd yr erthygl hon yn dangos rhai dulliau i chi o sut i newid lliw celloedd wrth glicio ar gell, a newid y lliw a amlygwyd wrth ddewis ystod o gelloedd yn Excel.

Newid lliw celloedd pan fydd cell yn cael ei chlicio gyda chod VBA
Newidiwch y lliw a amlygwyd pan ddewisir celloedd â chod VBA
Tynnwch sylw at y rhes gyfan a'r golofn o gell weithredol gyda Kutools ar gyfer Excel


Newid lliw celloedd pan fydd cell yn cael ei chlicio gyda chod VBA

Yma, gallwch newid lliw cefndir cell wrth ei chlicio ddwywaith neu glicio arni gyda'r cod VBA canlynol.

1. Yn y daflen waith byddwch chi'n newid lliw'r gell wrth glicio arni, cliciwch ar y dde ar y tab dalen a chlicio Gweld y Cod o'r ddewislen clicio ar y dde.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, copïwch a gludwch y cod VBA isod i'r Côd ffenestr.

VBA: newid lliw celloedd wrth glicio arno

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Target.Interior.Color = vbRed
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Target.Interior.Color = vbGreen
End Sub

3. Gwasgwch Alt + Q allweddi ar yr un pryd i gau'r Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

Yna, pan fyddwch chi'n clicio cell ddwywaith, bydd wedi'i lliwio mewn coch. A phan gliciwch ar dde ar gell, bydd wedi'i lliwio'n wyrdd. Gweler y screenshot:


Un clic i dynnu sylw at res a cholofn y gell a ddewiswyd yn Excel:

Kutools ar gyfer Excel's Cynllun Darllen mae cyfleustodau yn eich helpu i dynnu sylw at res a cholofn y gell a ddewiswyd yn Excel yn gyflym fel y demo isod.
Dadlwythwch a rhowch gynnig arni nawr! (llwybr am ddim 30 diwrnod)


Newidiwch y lliw a amlygwyd pan ddewisir celloedd â chod VBA

Yn ddiofyn, wrth ddewis ystod o gelloedd, mae'r lliw a amlygwyd yn llwyd. Os ydych chi am wneud yr ystod a ddewiswyd yn fwy sefyll allan, gallwch newid ei liw wedi'i amlygu i'r un sydd ei angen arnoch chi. Gwnewch fel a ganlyn.

1. De-gliciwch y tab dalen rydych chi am newid lliw wedi'i amlygu'r ystod a ddewiswyd, a chlicio Gweld y Cod o'r ddewislen clicio ar y dde.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, copïwch a gludwch y cod VBA isod i'r Côd ffenestr.

Cod VBA: newid lliw wedi'i amlygu'r ystod a ddewiswyd

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
        .Worksheet.Cells.FormatConditions.Delete
        .FormatConditions.Add xlExpression, , "TRUE"
        .FormatConditions(1).Interior.Color = vbYellow
    End With
End Sub

3. Gwasgwch Alt + Q allweddi ar yr un pryd i gau'r Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

O hyn ymlaen, mae lliw a amlygwyd yr ystod neu'r gell a ddewiswyd yn cael ei newid i felyn. Pan gliciwch gell arall neu ystod o gelloedd, bydd y celloedd yn cael eu lliwio'n awtomatig.


Tynnwch sylw at y rhes gyfan a'r golofn o gell weithredol gyda Kutools ar gyfer Excel

Os ydych chi'n delio â thaflen waith fawr, mae angen tynnu sylw at res a cholofn gyfan y gell actif er mwyn ei gwneud hi'n haws darllen. Yma mae'r Cynllun Darllen cyfleustodau Kutools ar gyfer Excel gallwch chi helpu.

Cyn gwneud cais Kutools ar gyfer Excel, os gwelwch yn dda ei lawrlwytho a'i osod yn gyntaf.

1. Cliciwch Kutools > Cynllun Darllen. Gweler y screenshot:

Yna mae'r cynllun darllen wedi'i alluogi, gallwch weld bod rhes a cholofn y gell weithredol yn cael eu hamlygu ar unwaith.

Nodyn: Gallwch newid y gosodiadau cynllun darllen yn seiliedig ar eich anghenion fel isod llun a ddangosir.

  Os ydych chi am gael treial am ddim (30 diwrnod) o'r cyfleustodau hwn, cliciwch i'w lawrlwytho, ac yna ewch i gymhwyso'r llawdriniaeth yn ôl y camau uchod.


Tynnwch sylw at y rhes gyfan a'r golofn o gell weithredol gyda Kutools ar gyfer 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 (28)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello, i built a dashboard with 37 worksheets, everyone with a table. All of them are lock panels because are to large and i need to know the number and name of the student who am i entering data for. Despite that, i have to keep my finger on the left side of the screen to identify the names and numbers to which the entered data refer.  So, i need to identify the first two cells of the row, in the columns "I" and "J".
The code that i took from the internet and couldn't change for the two cells of columns "I" and "J" was:

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

All tables begin in diferent rows. This example start in 16 row but i put the code in all the pages and adapt to the needs of the specific row number. 
I've already tried to change the code from EntireRow to Range ("I16:J43") but the cells were in the range became all painted with the code color.
Already try a diferent way through the "conditional formatting" with the formula =E($I16<>"";LIN()=CÉL("lin")) in the range $I16:$J43, and in the developer "worksheet", with "Application.Calculate" and it works. I change in the 37 worksheets but i was copying and data from the previous file to this new one and I noticed that the options to paste "values", etc, disappear from my dashboard. The code must be executing something that, like clicking on the cell, no longer lets it paste. A single option was to paste with CTRL+V.
If someone can help me with the code, i'll delete the VBA "Application.Calculate" to to get back to the available collage options.
Thak you for your help.

Luís Lopes
This comment was minimized by the moderator on the site
Hello, the code used to work for a while, but now it doesn't anymore. What can there be wrong?
This comment was minimized by the moderator on the site
Hi Rens Borburgh,There are two codes provided in the post, which one did you use? Did you get any error prompt?
This comment was minimized by the moderator on the site
I have tried them both at the same time. After copying it to a usb stick it didn't work anymore.
This comment was minimized by the moderator on the site
Hi Rens Borburgh,I don't quite understand what you mean. The codes should be used in the sheet code window and not in the Module window. Or can you provide a screenshot of your code window?
This comment was minimized by the moderator on the site
Hi, I am trying to use the double click option to change a cell to green but i also want that cell to go back to no fill or white if i double click it whilst it is green. Is this possible? 
This comment was minimized by the moderator on the site
alguien que me ayude solo quiero que al hacerle click a una celda se ponga de un color y que se mantenga ese color y si le vuelvo hacer click regrese el color original que tenia
This comment was minimized by the moderator on the site
How to highlight the cell(with data) to automatically highlight the other cells (data which is related another data in a previous cell) with click of the cell.Can i do it. Is there a way to do it.
This comment was minimized by the moderator on the site
The code works as long as I do not protect the worksheet. Once I protect the worksheet, because I have conditional formatting on locked cells, the code will not work. How can I change this so that it works on locked worksheet where the user can select unlocked cells?
This comment was minimized by the moderator on the site
Hi,
is it possible to have a code for "change cell color when clicking on it" in the way that it will not change already formated cells with another color, please?
After applying your code all my formating (colours) is away. Thank you. Veronika
This comment was minimized by the moderator on the site
Thank you. Great Job
This comment was minimized by the moderator on the site
hi
the is working grate but i want that the color should only be when the cell is selected and when i select something else, the first cell i selcted should not be colored
can you help me pls with this thanks
This comment was minimized by the moderator on the site
I had that exact same question! I hope someone will answer you! The reason I am looking for this is I have a spreadsheet I use daily and put in lots of information into single cells. It gets hard to see the values (visually, it runs into info in other cells), and would be a great feature if I could change the color of the cell being edited - only while it is being edited. The simplest solution I can think of is that the cell value would be set back to what it was prior to being clicked on - but I don't know how to do that.
This comment was minimized by the moderator on the site
Hi, I am trying to figure out how to change the color of a cell, based on a selection from a dropdown list. For example, HIGH=red, MEDIUM=yellow, LOW=green.

Any tips you can provide are greatly appreciated. Thank You
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