Как скрыть или показать указанные строки или столбцы при двойном щелчке по ячейке в Excel?
Обычно строки и столбцы можно скрыть или отобразить, щелкнув правой кнопкой мыши и выбрав параметр «Скрыть» или «Показать» в контекстном меню. В этой статье мы говорим о быстром скрытии или отображении определенных строк или столбцов двойным щелчком по ячейке в Excel.
Скрыть или отобразить указанные строки или столбцы при двойном щелчке ячейки с кодом VBA
- Повторное использование чего угодно: Добавляйте наиболее часто используемые или сложные формулы, диаграммы и все остальное в избранное и быстро используйте их в будущем.
- Более 20 текстовых функций: Извлечь число из текстовой строки; Извлечь или удалить часть текстов; Преобразование чисел и валют в английские слова.
- Инструменты слияния: Несколько книг и листов в одну; Объединить несколько ячеек / строк / столбцов без потери данных; Объедините повторяющиеся строки и сумму.
- Разделить инструменты: Разделение данных на несколько листов в зависимости от ценности; Из одной книги в несколько файлов Excel, PDF или CSV; От одного столбца к нескольким столбцам.
- Вставить пропуск Скрытые / отфильтрованные строки; Подсчет и сумма по цвету фона; Отправляйте персонализированные электронные письма нескольким получателям массово.
- Суперфильтр: Создавайте расширенные схемы фильтров и применяйте их к любым листам; Сортировать по неделям, дням, периодичности и др .; Фильтр жирным шрифтом, формулы, комментарий ...
- Более 300 мощных функций; Работает с Office 2007-2021 и 365; Поддерживает все языки; Простое развертывание на вашем предприятии или в организации.
Скрыть или отобразить указанные строки или столбцы при двойном щелчке ячейки с кодом VBA
Следующие коды VBA могут помочь вам быстро скрыть или отобразить указанные строки или столбцы на листе, дважды щелкнув определенную ячейку. Пожалуйста, сделайте следующее.
1. Откройте рабочий лист, внутри которого вы хотите скрыть строки или столбцы. Щелкните вкладку листа правой кнопкой мыши и выберите Просмотреть код из контекстного меню.
2. В дебюте Microsoft Visual Basic для приложений окно, скопируйте следующий код VBA в окно кода.
VBA: скрыть / отобразить указанные строки, дважды щелкнув ячейки на листе:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Updateby20171226
Dim xRgHidden As Range
If (Not Intersect(Target, Range("A1:A4")) Is Nothing) And (Target.Count = 1) Then
Set xRgHidden = Range("10:13")
xRgHidden.EntireRow.Hidden = Not xRgHidden.EntireRow.Hidden
End If
End Sub
VBA: Hide/unhide specified columns by double-clicking cells in worksheet:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Updateby20171226
Dim xRgHidden As Range
If (Not Intersect(Target, Range("A1:A4")) Is Nothing) And (Target.Count = 1) Then
Set xRgHidden = Range("D:E")
xRgHidden.EntireColumn.Hidden = Not xRgHidden.EntireColumn.Hidden
End If
End Sub
Note: In the code, A1:A4, 10:13 and D:E indicate that when double-clicking on any cell of the range A1:A4, the row 10:13 or column D:E will be hidden automatically.
3. Press the Alt + F11 keys to close the Microsoft Visual Basic for Applications window.
From now on, when double clicking any cell in range A1:A4, row 10:13 or column D:E will be hidden automatically. And double clicking the cell again to display all hidden rows or columns immediately.
Related Articles:
- How to click or double click cell to open a specified user form in Excel?
- How to add check mark in a cell with double clicking in Excel?
- How to auto add/enter current date/time in a cell with double clicking in Excel?
- How to double click a cell and add 1 to that cell value in Excel?
- How to pop up a calendar when clicking a specific cell in Excel?
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
- Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
- Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
- Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
- Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
- Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
- Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
- Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
- Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
- More than 300 powerful features. Supports Office / Excel 2007-2021 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Sort comments by
#35112
This comment was minimized by the moderator on the site
Report
0
0
#35113
This comment was minimized by the moderator on the site
Report
0
0
#35114
This comment was minimized by the moderator on the site
0
0
#36411
This comment was minimized by the moderator on the site
Report
0
0
There are no comments posted here yet