Тёмный

Highlight Row and Column of the Selected Cell - 2 Easy Methods 

Officeinstructor
Подписаться 81 тыс.
Просмотров 13 тыс.
50% 1

When working on a large list with column headers and row headers, you can improve the legibility of your data by highlighting the row and column of the selected cell, if you click on another cell, a different row and column are highlighted. But if you click outside the list nothing is highlighted.
In this tutorial I show you 2 methods for doing this either with Conditional Formatting or with a simple VBA code. Let me know in a comment which method you prefer.
So, let’s dive in.
Note:
When using the VBA method, the ro color and Column color extends beyond the range of data. I didn't want to deal with this situation to avoid a much more complicated code. If you are interested in solving this issue, then use this code instead replace the words greater than with the greater than symbol:
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Cells.Interior.Color = xlColorIndexNone
Dim Nabil As Range
Dim singlecell As Range
Set Nabil = Range ("A2:E25")
If Target.Row greater than26 Or Target.Column Greater than 5 Then
Cells.Interior.ColorIndex = xlColorIndexNone
Exit Sub
Else
For Each singlecell In Nabil
If singlecell.Row = ActiveCell.Row Or singlecell.Column = ActiveCell.Column Then
singlecell.Interior.ColorIndex = 6
End If
Next singlecell
End If
End Sub

Опубликовано:

 

9 авг 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 47   
@axion8788
@axion8788 Год назад
The master speaks. Those who seek wisdom listen.
@Officeinstructor
@Officeinstructor Год назад
Thank you so much.
@nadermounir8228
@nadermounir8228 Год назад
I find a huge benefit from this tutorial. your conditional formatting solution is far better than VBA because it doesn't highlight the entire column but rather the highlight the row and column within the range only. the tutorial is amazing and your Conditional formatting solution is unique. Thanks for this great tutorial and for showing us VBA. 👍
@Officeinstructor
@Officeinstructor Год назад
I agree Nader, Conditional formatting is efficient, dynamic and easy. However, I can limit the highlighting to just the range using VBA as well but the code will be much more complicated. I added this code to the video description. Thank you for being a loyal subscriber
@user-ie3rr1tr4d
@user-ie3rr1tr4d Год назад
This video along with the additional comments allowed me to come up with a working solution that highlights only rows in a list range not starting in Column A and Row and also one that will be extended. Excellent thanks.
@deepakmirchandani1348
@deepakmirchandani1348 Год назад
thanks sir for clearly and slowly explaining these exclusive methods. thanks a lot.
@mswordexpert
@mswordexpert Год назад
thanks a lot. regarding to your question... you can revile the number of the columns by enabling this option: file > Options> Formulas > R1C1 reference style
@Officeinstructor
@Officeinstructor Год назад
Yes, you are right... Excellent
@redhaakhund1271
@redhaakhund1271 Год назад
Thank you so much and really smart solutions. As always, your videos and explanation are excellent. All the best and looking forward to more videos.👍👍👍👍👍
@vivekphadke16
@vivekphadke16 Год назад
Simple and very useful, even a person not trained in VBA can create such file and use it (thanks to your video and commentary) I prefer VBA for long term solution.
@Officeinstructor
@Officeinstructor Год назад
Glad to hear that
@MananKalantre
@MananKalantre Год назад
Marvelous Nabil sir 👌🏻
@Saad.PS2009
@Saad.PS2009 Год назад
Very clear and useful explanation
@Officeinstructor
@Officeinstructor Год назад
Glad you liked it my friend. Shokran Gazilan
@mohammadmohammad-yv4md
@mohammadmohammad-yv4md Год назад
Nabeel you r the best!!
@Officeinstructor
@Officeinstructor Год назад
Enta 7abibi
@alializadeh8195
@alializadeh8195 Год назад
Thanks
@Al-Ahdal
@Al-Ahdal Год назад
1st comment, I prefer conditional formatting.
@Officeinstructor
@Officeinstructor Год назад
I agree with you Syed...Thanks for watching
@IvanCortinas_ES
@IvanCortinas_ES Год назад
Last row with data =MAX((A:A"")*ROW((A:A))) Last column with data =MAX((1:1"")*COLUMN((1:1))) (Assuming an homogeneous data range like the one in the example)
@Officeinstructor
@Officeinstructor Год назад
That's beautiful Ivan, thanks for sharing
@vadodarajilla8117
@vadodarajilla8117 Год назад
This works, but the biggest problem is that copy and paste function does not work after putting this in place
@martyc5674
@martyc5674 Год назад
Great Video- I prefer cond formatting as it works on the web, but there’s still that one line of VBA, would you know if there’s script to overcome this?
@Officeinstructor
@Officeinstructor Год назад
I agree. Conditional formatting is simple
@dannyhsu5612
@dannyhsu5612 Год назад
I need help. Somehow when I use the conditional formatting, it doesn't highlight the rows or columns.
@Rkeev1
@Rkeev1 Год назад
If you add a volatile function there is no need for vba or calculate, correct? Like placing &t(now()) at the end of ur cond format formula
@Officeinstructor
@Officeinstructor Год назад
The concept makes sense but it didn't work for me
@yosefk2864
@yosefk2864 Год назад
Thanks for sharing this. How would you in the vba example adapt the code so that the highlighting of rows and columns won't go beyond the used rows and columns?
@Officeinstructor
@Officeinstructor Год назад
That's a very good point. Honestly, I didn't want to do it that way because the code will be different and more complicated. Here is the code, just for you Private Sub Worksheet_SelectionChange(ByVal Target As Range) Cells.Interior.Color = xlColorIndexNone Dim Nabil As Range Dim singlecell As Range Set Nabil = Range("A2:E25") If Target.Row > 26 Or Target.Column > 5 Then Cells.Interior.ColorIndex = xlColorIndexNone Exit Sub Else For Each singlecell In Nabil If singlecell.Row = ActiveCell.Row Or singlecell.Column = ActiveCell.Column Then singlecell.Interior.ColorIndex = 6 End If Next singlecell End If End Sub Test it (after customizing the range) and let me know what you think
@vivekphadke16
@vivekphadke16 Год назад
@@Officeinstructor cool
@yosefk2864
@yosefk2864 Год назад
@@Officeinstructor Works perfect. Wasn't much of a problem to make the range dynamic. Thanks!
@ivaniffah1039
@ivaniffah1039 Год назад
@@Officeinstructor Sir, I used Conditional Formatting and VBA both but when using VBA I cant undo anything that I have previously done. Is there any way to have redo undo option. another thing using Conditional formatting, I cant highlight multiple rows and columns when select multiple cells as like when selecting C5:C10 or C5:D10 the corresponding rows and columns are not highlighting.
@onurtunc9468
@onurtunc9468 9 месяцев назад
thanks for instruction. i m looking for more efficient way to use in huge data lists. in your example code works fast but huge list this code works slow. i researched so many topics for fastest way unfortunatelly i couldnt find. microsoft may add this highlight function in excel. this is the code for calculation: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Row < shDefter.ListObjects("tblDefter").ListRows.Count Then Application.Calculate End If End Sub
@msamamah
@msamamah Год назад
This is great, But I need to know how to make it when I search in a data in the table, then the required Data with the row return at the first row. Thank you in advance
@Officeinstructor
@Officeinstructor Год назад
Thanks Mohammad for watching my tutorial. If I understand properly, The same functionality should work in a table.
@michaelt312
@michaelt312 Год назад
Using conditional formatting, is there a way to make the selected cell one color and the row and column another color? As an example, bright yellow for the selected cell and a less vibrant shade for the row and column.
@Officeinstructor
@Officeinstructor Год назад
try to add another rule. Select the range , say A2:E25 In the new rule dialog box, type the formula: =A2=INDIRECT(CELL("address")) select the format color you want and hit OK Test it and let me know if it works
@vivekphadke16
@vivekphadke16 Год назад
@@Officeinstructor only thing is you need to double click the cell you are selecting
@ivaniffah1039
@ivaniffah1039 Год назад
HELLO, DO YOU KNOW HOW TO USE CONDITIONAL FORMATING TO HIGHLIGH ROWS AND COLUMNS WHEN MULTIPLE CELLS ARE SELECTED. SUCH AS WHEN SELECTED FROM A3 TO D5 WITHIN A RANGE THE COLUMN FROM A TO D AND ROW FROM 3 TO 5 ARE HIGHLIGHTED. THIS NEEDS TO BE DYNAMIC TOO. THANKS IN ADVANCE.
@ivaniffah1039
@ivaniffah1039 Год назад
Sir I want to highlight columns and rows for corresponding selected multiple cells using conditional formatting. Please can you help?
@sumeetkedar9214
@sumeetkedar9214 Год назад
I find condition formatting method more simpler😊
@mvparker79
@mvparker79 Год назад
Very cool...however I can no longer copy+paste. hahahaha
@donaldpurdy2762
@donaldpurdy2762 5 месяцев назад
I listened watched the entire video. I copied the formula exact ... to include what was upper case and what was lower case. I entered the formula exactly as written in 'Conditional Formatting' under New Rule and Every time I hit the second OK after selecting the Fill color .... The formula is not accepted. This does not work in the Excel version (MS 365) I am using.
@Officeinstructor
@Officeinstructor 4 месяца назад
I'm surprised. It works in any version. But I can't tell what the problem is unless I see it. Try watch again ... minor details make big differences
@usmaniqbal1836
@usmaniqbal1836 Год назад
Nabil Bhai please share excel file for practice
@Officeinstructor
@Officeinstructor Год назад
You can create the functionality in any Excel file you have. Nothing special in my file.
@usmaniqbal1836
@usmaniqbal1836 Год назад
@@Officeinstructor Not again
Далее
How to get the Last Row in VBA(The Right Way!)
15:41
Просмотров 153 тыс.
Highlight Active Row & Column in Excel (7 Levels)
22:56