Opomba: Drugi jeziki spletnega mesta so prevedeni z Googlom. Nazaj na angleščino
Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako spremeniti barvo celice, ko v Excelu kliknemo ali izberemo celico?

Ta članek vam bo pokazal nekaj metod, kako spremenite barvo celice med klikom na celico in spremenite označeno barvo med izbiro obsega celic v Excelu.

Ko kliknete celico s kodo VBA, spremenite barvo celice
Spremenite označeno barvo, ko so celice izbrane s kodo VBA
Označite celotno vrstico in stolpec aktivne celice s Kutools za Excel


Ko kliknete celico s kodo VBA, spremenite barvo celice

Tu lahko spremenite barvo ozadja celice, ko jo dvokliknete ali z desno miškino tipko kliknete z naslednjo kodo VBA.

1. Na delovnem listu boste spremenili barvo celice, ko jo kliknete, z desno miškino tipko kliknite jeziček lista in kliknite Ogled kode v meniju z desnim klikom.

2. V Ljubljani Microsoft Visual Basic za aplikacije okno, kopirajte in prilepite spodnjo kodo VBA v Koda okno.

VBA: ob kliku nanjo spremenite barvo celice

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. Pritisnite druga + Q tipke hkrati, da zaprete tipko Microsoft Visual Basic za aplikacije okno.

Potem, ko dvokliknete celico, bo ta obarvana rdeče. In ko z desno miškino tipko kliknete celico, bo ta obarvana v zeleno. Oglejte si posnetek zaslona:


Z enim klikom označite vrstico in stolpec izbrane celice v Excelu:

Kutools za Excel's Bralna postavitev pripomoček vam pomaga hitro poudariti vrstico in stolpec izbrane celice v Excelu, kot je prikazano spodaj.
Prenesite in poskusite zdaj! (30-dnevna brezplačna pot)


Spremenite označeno barvo, ko so celice izbrane s kodo VBA

Pri izbiri obsega celic je privzeto označena siva barva. Če želite izbrani obseg bolj izstopati, lahko njegovo označeno barvo spremenite v tisto, ki jo potrebujete. Naredite naslednje.

1. Z desno miškino tipko kliknite jeziček lista, za katerega želite spremeniti označeno barvo izbranega obsega, in kliknite Ogled kode v meniju z desnim klikom.

2. V Ljubljani Microsoft Visual Basic za aplikacije okno, kopirajte in prilepite spodnjo kodo VBA v Koda okno.

Koda VBA: spremenite označeno barvo izbranega obsega

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. Pritisnite druga + Q tipke hkrati, da zaprete Microsoft Visual Basic za aplikacije okno.

Od zdaj naprej se označena barva izbranega obsega ali celice spremeni v rumeno. Ko kliknete drugo celico ali obseg celic, bodo celice samodejno obarvane.


Označite celotno vrstico in stolpec aktivne celice s Kutools za Excel

Če imate opravka z velikim delovnim listom, morate za lažje branje označiti celotno vrstico in stolpec aktivne celice. Tukaj Bralna postavitev uporabnost Kutools za Excel vam lahko pomaga.

Pred vložitvijo vloge Kutools za ExcelProsim najprej ga prenesite in namestite.

1. klik Kutools > Bralna postavitev. Oglejte si posnetek zaslona:

Potem je postavitev branja omogočena, vidite lahko, da sta vrstica in stolpec aktivne celice takoj označena.

Opombe: Nastavitve postavitve branja lahko spremenite glede na vaše potrebe, kot je prikazano spodaj.

  Če želite imeti brezplačno (30-dnevno) preskusno različico tega pripomočka, kliknite, če ga želite prenestiin nato nadaljujte z uporabo postopka v skladu z zgornjimi koraki.


Označite celotno vrstico in stolpec aktivne celice s Kutools za Excel


Najboljša orodja za pisarniško produktivnost

Kutools za Excel rešuje večino vaših težav in poveča produktivnost za 80%

  • Ponovna uporaba: Hitro vstavite zapletene formule, grafikoni in vse, kar ste že uporabljali; Šifriraj celice z geslom; Ustvari poštni seznam in pošiljanje e-pošte ...
  • Vrstica Super Formula (enostavno urejanje več vrstic besedila in formule); Bralna postavitev (enostavno branje in urejanje velikega števila celic); Prilepite v filtrirani obseg...
  • Združi celice / vrstice / stolpce brez izgube podatkov; Vsebina razdeljenih celic; Združi podvojene vrstice / stolpce... prepreči podvojene celice; Primerjaj obsege...
  • Izberite Duplicate ali Unique Vrstice; Izberite prazne vrstice (vse celice so prazne); Super Find in Fuzzy Find v mnogih delovnih zvezkih; Naključna izbira ...
  • Natančna kopija Več celic brez spreminjanja sklica formule; Samodejno ustvarjanje referenc na več listov; Vstavi oznake, Potrditvena polja in še več ...
  • Izvleček besedila, Dodaj besedilo, Odstrani po položaju, Odstrani presledek; Ustvari in natisni vmesne seštevke strani Pretvarjanje med vsebino celic in komentarji...
  • Super filter (shranite in uporabite sheme filtrov za druge liste); Napredno razvrščanje glede na mesec / teden / dan, pogostost in drugo; Poseben filter s krepko, ležeče ...
  • Združite delovne zvezke in delovne liste; Spoji tabele na podlagi ključnih stolpcev; Razdelite podatke na več listov; Paketna pretvorba xls, xlsx in PDF...
  • Več kot 300 zmogljivih funkcij. Podpira Office / Excel 2007-2019 in 365. Podpira vse jezike. Preprosta namestitev v vašem podjetju ali organizaciji. Vse funkcije 30-dnevnega brezplačnega preskusa. 60-dnevno jamstvo za vračilo denarja.
zavihek kte 201905

Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50% in vsak dan zmanjša na stotine klikov z miško!
dno pisarniške mize
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Vera · 7 months ago
    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
  • To post as a guest, your comment is unpublished.
    kiba fil · 1 years ago
    Thank you. Great Job
  • To post as a guest, your comment is unpublished.
    shea honig · 1 years ago
    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
    • To post as a guest, your comment is unpublished.
      Kris · 10 months ago
      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.
  • To post as a guest, your comment is unpublished.
    perry · 1 years ago
    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
  • To post as a guest, your comment is unpublished.
    Vishnu Subind · 1 years ago
    Hi guys, so i used to first code to change the cell colour to green/red on doubleclick/rightclick. I would like this code, however, to work just on a specific range of cells, in my case D9:P9. can someone help me on how to do that? Im new at VBA
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi,
      The below VBA code can do you a favor, please have a try. Thank you for your comment.

      Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
      If (Not Application.Intersect(Target, Me.Range("D9:P9")) Is Nothing) Then
      Cancel = True
      Target.Interior.Color = vbRed
      End If
      End Sub
      Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
      If (Not Application.Intersect(Target, Me.Range("D9:P9")) Is Nothing) Then
      Cancel = True
      Target.Interior.Color = vbGreen
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    rahayu · 1 years ago
    trimakasih
  • To post as a guest, your comment is unpublished.
    rahayu · 1 years ago
    td muncul=tidak muncul
  • To post as a guest, your comment is unpublished.
    rahayu · 1 years ago
    Salam...
    sy sudah install kutools, tp kok td muncul tab kutools di layar excel ya? gmn cara mmunculkannya?trimakasih
  • To post as a guest, your comment is unpublished.
    vuongngocsangbkdn@gmail.com · 2 years ago
    I have a problem.
    I want change color of one hyperlink if it had linked with one PDF to RED and if had not link with one PDF will show BLUE color.
    How can I do now?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Sorry can't help you with that. Thanks for commenting.
  • To post as a guest, your comment is unpublished.
    devika.kalika@gmail.com · 2 years ago
    I tried the "Change the highlighted color when cells are selected with VBA code" option and saved my excel as Macro Enabled Worksheet. Now the last cells that were selected are highlighted and won't highlight other cells when selected. I've deleted code and reentered and saved, but still no change. I can't remove the previous highlight either. I'm at lost on what to do.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi,
      The code works well in my case after saving the workbook as an Excel Macro-Enabled Workbook.
      Can you tell me your Excel version?
  • To post as a guest, your comment is unpublished.
    Jason · 2 years ago
    Is there a way to just apply this to certain cells while leaving other cells with available for number entering?
  • To post as a guest, your comment is unpublished.
    Slaxx · 2 years ago
    hi. just a little heads up. i'm using office 2007.
    i tried your code, and while it did work, it wasn't what i was looking for. so i just deleted the code completely. but the last selected/active cell before i deleted the code is still green (i changed the color from vbYellow to vbGreen), and the color won't go away. it's not affected by fill color either.
    the simplest solution i found was to just delete the cell. copying and pasting will not work, it will also copy the color.
    just thought i'd let you know. you might find another solution/troubleshooting for this, besides deleting and manual entry. still, thanks! i confirm that the code works :)
  • To post as a guest, your comment is unpublished.
    Michelle · 2 years ago
    I love how easy formatting my worksheet the code for "change cell color when clicking on it" would make my daily work! I am hitting a snag though. When I copy my Blank Sheet with the code entered as described, I get a error. It runs great until I create new sheets. I am a novice at coding and am working from textbooks and the internet. I appreciate any help you will offer!
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Dear Michelle,
      I followed the steps as you described, but the code also worked in my case. Can you tell me your Office version?
      Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    madhav neupane · 3 years ago
    thank you thank you so much. I appreciate you for this.