Ga naar hoofdinhoud

Hoe verander ik de celkleur wanneer er op een cel wordt geklikt of geselecteerd in Excel?

Dit artikel laat u enkele methoden zien om de celkleur te wijzigen terwijl u op een cel klikt, en de gemarkeerde kleur te wijzigen terwijl u een celbereik in Excel selecteert.

Verander de celkleur wanneer er op de cel wordt geklikt met VBA-code
Verander de gemarkeerde kleur wanneer cellen zijn geselecteerd met VBA-code
Markeer de hele rij en kolom met actieve cellen met Kutools voor Excel


Verander de celkleur wanneer er op de cel wordt geklikt met VBA-code

Hier kunt u de achtergrondkleur van een cel wijzigen door erop te dubbelklikken of er met de rechtermuisknop op te klikken met de volgende VBA-code.

1. In het werkblad wijzigt u de celkleur door erop te klikken, klik met de rechtermuisknop op de bladtab en klik Bekijk code vanuit het rechtsklikmenu.

2. In de Microsoft Visual Basic voor toepassingen -venster, kopieer en plak de onderstaande VBA-code in het Code venster.

VBA: verander de celkleur door erop te klikken

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. druk op anders + Q toetsen tegelijk om het Microsoft Visual Basic voor toepassingen venster.

Als u vervolgens dubbelklikt op een cel, wordt deze rood gekleurd. En als u met de rechtermuisknop op een cel klikt, wordt deze groen gekleurd. Zie screenshot:


E茅n klik om rij en kolom van geselecteerde cel in Excel te markeren:

Kutools for Excel's Lay-out lezen hulpprogramma helpt u snel de rij en kolom van de geselecteerde cel in Excel te markeren, zoals de onderstaande demo laat zien.
Download en probeer het nu! (30 dagen gratis proefperiode)


Verander de gemarkeerde kleur wanneer cellen zijn geselecteerd met VBA-code

Standaard is bij het selecteren van een celbereik de gemarkeerde kleur grijs. Als u het geselecteerde bereik meer wilt laten opvallen, kunt u de gemarkeerde kleur wijzigen in de kleur die u nodig hebt. Ga als volgt te werk.

1. Klik met de rechtermuisknop op de bladtab waarvan u de gemarkeerde kleur van het geselecteerde bereik wilt wijzigen, en klik Bekijk code vanuit het rechtsklikmenu.

2. In de Microsoft Visual Basic voor toepassingen -venster, kopieer en plak de onderstaande VBA-code in het Code venster.

VBA-code: verander de gemarkeerde kleur van het geselecteerde bereik

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. druk op anders + Q toetsen tegelijkertijd om de Microsoft Visual Basic voor toepassingen venster.

Vanaf nu wordt de gemarkeerde kleur van het geselecteerde bereik of de geselecteerde cel gewijzigd in geel. Wanneer u op een andere cel of celbereik klikt, worden de cellen automatisch gekleurd.


Markeer de hele rij en kolom met actieve cellen met Kutools voor Excel

Als u te maken heeft met een groot werkblad, is het noodzakelijk om de hele rij en kolom van de actieve cel te markeren om het lezen gemakkelijker te maken. Hier de Lay-out lezen nut van Kutools for Excel kan jou helpen.

Voor het aanvragen Kutools for Excel, Dan kunt u download en installeer het eerst.

1. klikken Kutools > Lay-out lezen. Zie screenshot:

Vervolgens is de leeslay-out ingeschakeld, u kunt zien dat de rij en kolom van de actieve cel onmiddellijk worden gemarkeerd.

Note: U kunt de instellingen voor de leeslay-out wijzigen op basis van uw behoeften, zoals hieronder wordt getoond.

  Als u een gratis proefperiode (30 dagen) van dit hulpprogramma wilt, klik om het te downloaden, en ga vervolgens de bewerking toepassen volgens de bovenstaande stappen.


Markeer de hele rij en kolom met actieve cellen met Kutools voor Excel

Beste Office-productiviteitstools

馃 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten   |  Verwijder lege rijen   |  Combineer kolommen of cellen zonder gegevens te verliezen   |   Ronde zonder formule ...
Super opzoeken: Meerdere criteria VLookup    VLookup met meerdere waarden  |   VOpzoeken over meerdere bladen   |   Fuzzy opzoeken ....
Geavanceerde vervolgkeuzelijst: Maak snel een vervolgkeuzelijst   |  Afhankelijke vervolgkeuzelijst   |  Multi-select vervolgkeuzelijst ....
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  |  Vergelijk bereiken en kolommen ...
Uitgelichte functies: Raster focus   |  Ontwerpweergave   |   Grote formulebalk    Werkmap- en bladbeheer   |  resource Library (Auto-tekst)   |  Datumkiezer   |  Combineer werkbladen   |  Cellen coderen/decoderen    Stuur e-mails per lijst   |  Super filter   |   Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen, ...)   |   50+ tabel Types (Gantt Chart, ...)   |   40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag, ...)   |   19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad, ...)   |   12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion, ...)   |   7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Gespleten cellen, ...)   |   ... en meer

Geef uw Excel-vaardigheden een boost met Kutools voor Excel en ervaar effici毛ntie als nooit tevoren. Kutools voor Excel biedt meer dan 300 geavanceerde functies om de productiviteit te verhogen en tijd te besparen.  Klik hier om de functie te krijgen die u het meest nodig heeft...

Omschrijving


Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert honderden muisklikken voor u elke dag!
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