Բաց թողնել հիմնական բովանդակությունը

Ինչպե՞ս Excel- ում առանձնացնել ակտիվ բջիջը կամ ընտրությունը:

Եթե ​​ունեք մեծ աշխատաթերթ, միգուցե ձեզ համար դժվար է մեկ հայացքից պարզել ակտիվ բջիջը կամ ակտիվ ընտրությունը: Եթե ​​պարզ լինի, որ ակտիվ բջիջը / հատվածը առանձնանում է գույնով, պարզել, որ դա խնդիր չի լինի: Այս հոդվածում ես կխոսեմ այն ​​մասին, թե ինչպես Excel- ում ավտոմատ կերպով առանձնացնել ակտիվ բջիջը կամ բջիջների ընտրված շարքը:

Առանձնացրեք ակտիվ բջիջը կամ ընտրությունը VBA կոդով


նետ կապույտ աջ պղպջակ Առանձնացրեք ակտիվ բջիջը կամ ընտրությունը VBA կոդով

Հետևյալ VBA կոդը կարող է օգնել ձեզ դինամիկորեն ընդգծել ակտիվ բջիջը կամ ընտրությունը, արեք հետևյալը.

1, Պահեք պահեք ALT + F11 բացել ստեղները Microsoft Visual Basic հավելվածների համար պատուհան:

2. Այնուհետեւ ընտրեք Այս գործառույթը ձախից Project Explorer, կրկնակի կտտացրեք այն `բացելու համար Մոդուլներև ապա պատճենեք և կպցրեք հետևյալ VBA կոդը ՝ դատարկ Մոդուլի մեջ.

VBA կոդ. Կարևորել ակտիվ բջիջը կամ ընտրությունը

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-highlight-active-cell-1

3, Դրանից հետո պահեք և փակեք այս կոդը և վերադառնաք աշխատաթերթ, հիմա, երբ բջիջ կամ ընտրություն եք ընտրում, ընտրված բջիջները կարևորվում են, և այն դինամիկ կերպով կտեղափոխվի ընտրված բջիջների փոփոխության հետ:

Նշումներ:

1. Եթե չես կարող գտնել այն Project Explorer- ի պատուհան պատուհանում կարող եք սեղմել Դիտել > Project Explorer է Microsoft Visual Basic հավելվածների համար պատուհան բացելու համար:

2. Վերոնշյալ ծածկագրում կարող եք փոխել .ColorIndex = 6 գույնը ձեզ դուր եկած այլ գույնի:

3. Այս VBA կոդը կարող է կիրառվել աշխատանքային գրքի բոլոր աշխատանքային թերթերի վրա:

4. Եթե ձեր աշխատաթերթում կան մի քանի գունավոր բջիջներ, գույնը կկորչի, երբ կտտացրեք բջիջը, այնուհետև տեղափոխվեք այլ բջիջ:


Առնչվող հոդված:

Ինչպե՞ս Excel- ում ավտոմատ կերպով ընդգծել ակտիվ բջիջի տողն ու սյունը:

Գրասենյակի արտադրողականության լավագույն գործիքները

🤖 Kutools AI օգնականՀեղափոխություն կատարել տվյալների վերլուծության հիման վրա՝ Խելացի կատարում   |  Ստեղծեք ծածկագիր  |  Ստեղծեք հատուկ բանաձևեր  |  Վերլուծել տվյալները և ստեղծել գծապատկերներ  |  Invoke Kutools-ի գործառույթները...
Հանրաճանաչ հատկություններ: Գտեք, ընդգծեք կամ նույնականացրեք կրկնօրինակները   |  Deleteնջել դատարկ շարքերը   |  Միավորել սյունակները կամ բջիջները՝ առանց տվյալների կորստի   |   Կլոր առանց բանաձևի ...
Super Փնտրել: Բազմաթիվ չափանիշների VLookup    Բազմակի արժեք VLookup  |   VLookup բազմաթիվ թերթերում   |   Fuzzy Փնտրել ....
Ընդլայնված բացվող ցուցակ: Արագ ստեղծեք բացվող ցուցակը   |  Կախված բացվող ցուցակ   |  Բազմակի ընտրություն Drop Down ցուցակ ....
Սյունակի կառավարիչ: Ավելացրեք որոշակի քանակությամբ սյունակներ  |  Տեղափոխել սյունակները  |  Փոխարկել թաքնված սյունակների տեսանելիության կարգավիճակը  |  Համեմատեք միջակայքերը և սյունակները ...
Առանձնահատկություններ: Ցանցի կենտրոնացում   |  Դիզայնի տեսք   |   Մեծ Formula Bar    Աշխատանքային գրքույկի և թերթիկների կառավարիչ   |  Ռեսուրսների գրադարան (Ավտոմատ տեքստ)   |  Ամսաթիվ ընտրող   |  Միավորել աշխատանքային թերթերը   |  Գաղտնագրել/գաղտնազերծել բջիջները    Ուղարկեք նամակներ ըստ ցանկի   |  Սուպեր զտիչ   |   Հատուկ զտիչ (զտել թավ/շեղ/շեղված...) ...
Լավագույն 15 գործիքների հավաքածու12 Տեքստ Գործիքներ (Ավելացրեք տեքստ, Հեռացնել նիշերը, ...)   |   50+ Աղյուսակ Տեսակներ (Գանտի աղյուսակը, ...)   |   40+ Գործնական Բանաձեւեր (Հաշվարկել տարիքը ՝ ելնելով ծննդյան տարեդարձից, ...)   |   19 միացում Գործիքներ (Տեղադրեք QR կոդ, Տեղադրեք նկար ուղուց, ...)   |   12 Փոխարկում Գործիքներ (Բառեր համարներ, Արտարժույթի փոխակերպումը, ...)   |   7 Միաձուլում և պառակտում Գործիքներ (Ընդլայնված կոմբինատ տողեր, Պառակտված բջիջներ, ...)   |   ... եւ ավելին

Լրացրեք ձեր Excel-ի հմտությունները Kutools-ի հետ Excel-ի համար և փորձեք արդյունավետությունը, ինչպես երբեք: Kutools-ը Excel-ի համար առաջարկում է ավելի քան 300 առաջադեմ առանձնահատկություններ՝ արտադրողականությունը բարձրացնելու և ժամանակ խնայելու համար:  Սեղմեք այստեղ՝ Ձեզ ամենաշատ անհրաժեշտ հատկանիշը ստանալու համար...

Նկարագրություն


Office Tab- ը Tabbed ինտերֆեյսը բերում է Office, և ձեր աշխատանքը շատ ավելի դյուրին դարձրեք

  • Միացնել ներդիրներով խմբագրումը և ընթերցումը Word, Excel, PowerPoint- ով, Հրատարակիչ, Access, Visio և Project:
  • Բացեք և ստեղծեք բազմաթիվ փաստաթղթեր նույն պատուհանի նոր ներդիրներում, այլ ոչ թե նոր պատուհաններում:
  • Բարձրացնում է ձեր արտադրողականությունը 50%-ով և նվազեցնում մկնիկի հարյուրավոր սեղմումները ձեզ համար ամեն օր:
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