- Deselect a selected cell in Excel. How to multi select cells or ranges. This has not changed, you can still use the CTRL (or Command on Mac) key to click on an unselected cell to select it. To select an additional range simple use the CTRL (or Command on mac), starting on a unselected cells and drag the mouse to select the range.
- To reference to another sheet using an Array formula, select the cells in the Target worksheet first. For example: Select C8:E8. Press the equal sign, and then click on the worksheet that contains the Source data. Highlight the relevant source data cells. Press Enter to enter the formula into the Target worksheet.
- To batch rename your files using Mac Automator: Select “Finder,” “Applications folder,” then click on the “Automator app.”. Basic’s macro in Excel: In a new worksheet, in one.
- Mac Automator App Select Cells Excel List Script your own actions Mac Automator App Select Cells Excel Pdf. If the task you need to automate isn’t in the list of built-in actions, you can add your own scripts, such as AppleScript and JavaScript scripts, and shell commands to your workflow.
- Automator App Select Cells Excel Free
- Automator App Select Cells Excel
- Automator App Select Cells Excel Download
- Automator App Select Cells Excel Online
Microsoft Excel is one of those ubiquitous tools most of us can’t escape even if we tried. Many IT professionals use Excel as a little database storing tons of data in various automation routines. What’s the best scenario of automation and Excel? PowerShell!
In order to select the blank cells in a column and fill them with a formula, we start by selecting all of the cells (including the populated cells). There are many ways to do this, including holding the Shift key down while you navigate to the bottom of your column, or if your data is in an Excel Table, using the keyboard shortcut Ctrl + Space.
Excel spreadsheets have always been notoriously hard to script and automate. Unlike it’s less-featured (and simpler) CSV file counterpart, Excel workbooks aren’t just simple text files. Excel workbooks required PowerShell to manipulate complicated Component Object Model (COM) objects thus you had to have Excel installed. Not anymore.
Thankfully, an astute PowerShell community member, Doug Finke, created a PowerShell module called ImportExcel for us mere mortals. The ImportExcel module abstracts away all of that complexity. It makes it possible to easily manage Excel workbooks and get down to PowerShell scripting!
In this article, let’s explore what you can do with PowerShell and Excel using the ImportExcel module and a few popular use cases.
Prerequisites
When running the ImportExcel module on a Windows system, no separate dependencies are necessary. However, if you’re working on macOS, you will need to install the mono-libgdiplus package using brew install mono-libgdiplus
. All examples in this article will be built using macOS but all examples should work cross-platform.
If you’re using macOS, be sure to restart your PowerShell session before continuing.
Installing the ImportExcel Module
Start by download and installing the module via the PowerShell Gallery by running Install-Module ImportExcel -Scope CurrentUser
. After a few moments, you’ll be good to go.
Using PowerShell to Export to an Excel Worksheet
You may be familiar with the standard PowerShell cmdlets Export-Csv
and Import-Csv
. These cmdlets allow you to read and export PowerShell objects to CSV files. Unfortunately, there’s no Export-Excel
and Import-Excel
cmdlets. But using the ImportExcel module, you can build your own functionality.
One of the most common requests a sysadmin has is exporting PowerShell objects to an Excel worksheet. Using the Export-Excel
cmdlet in the ImportExcel module, you can easily make it happen.
For example, perhaps you need to find some processes running on your local computer and get them into an Excel workbook.
The Export-Excel
cmdlet accepts any object exactly the way Export-Csv
does. You can pipe any kind of object to this cmdlet.
To find processes running on a system with PowerShell, use the Get-Process
cmdlet which returns each running process and various information about each process. To export that information to Excel, use the Export-Excel
cmdlet providing the file path to the Excel workbook that will be created. You can see an example of the command and screenshot of the Excel file generated below.
Congrats! You’ve now exported all the information just like Export-Csv
but, unlike Export-Csv
, we can make this data a lot fancier. Let’s make sure the worksheet name is called Processes, the data is in a table and rows are auto-sized.
By using the AutoSize
switch parameter to autosize all rows, TableName
to specify the name of the table that will include all the data and the WorksheetName
parameter name of Processes, you can see in the screenshot below what can be built.
The Export-Excel
cmdlet has a ton of parameters you can use to create Excel workbooks of all kinds. For a full rundown on everything Export-Excel
can do, run Get-Help Export-Excel
.
Using PowerShell to Import to Excel
So you’ve exported some information to a file called processes.xlsx in the previous section. Perhaps now you need to move this file to another computer and import/read this information. No problem. You have Import-Excel
at your disposal.
At its most basic usage, you only need to provide the path to the Excel document/workbook using the Path
parameter as shown below. You’ll see that it reads the first worksheet, in this case, the Processes worksheet, and returns PowerShell objects.
Automator App Select Cells Excel Free
Maybe you have multiple worksheets in an Excel workbook? You can read a particular worksheet using the WorksheetName
parameter.
Do you need to only read certain columns from the Excel worksheet? Use the HeaderName
parameter to specify only those parameters you’d like to read.
The Import-Excel
cmdlet has other parameters you can use to read Excel workbooks of all kinds. For a full rundown on everything Import-Excel
can do, run Get-Help Import-Excel
.
Using PowerShell to Get (and Set) Excel Cell Values
You now know how to read an entire Excel worksheet with PowerShell but what if you only need a single cell value? You technically could use Import-Excel
and filter out the value you need with Where-Object
but that wouldn’t be too efficient.
Instead, using the Open-ExcelPackage
cmdlet, you can “convert” an Excel workbook into a PowerShell object which can then be read and manipulated. To find a cell value, first, open up the Excel workbook to bring it into memory.
The Open-ExcelPackage
is similar to using New-Object -comobject excel.application
if working directly with COM objects.
Next, pick the worksheet inside of the workbook.
This process is similar to the COM object way of opening workbooks with excel.workbooks.open
.
Once you have the worksheet assigned to a variable, you can now drill down to individual rows, columns, and cells. Perhaps you need to find all cell values in the A1 row. You simply need to reference the Cells
property providing an index of A1 as shown below.
You can also change the value of cells in a worksheet by assigning a different value eg. $worksheet.Cells['A1'] = 'differentvalue'
Once in memory, it’s important to release the Excel package using the Close-ExcelPackage
cmdlet.
Converting Excel to CSV Files with PowerShell
Once you have the contents of an Excel worksheet represented via PowerShell objects, “converting” Excel worksheets to CSV simply requires sending those objects to the Export-Csv
cmdlet.
Using the processes.xlsx workbook created earlier, read the first worksheet which gets all of the data into PowerShell objects and then export those objects to CSV using the command below.
If you now open up the resulting CSV file, you’ll see the same data inside of the Processes worksheet (in this example).
Converting Multiple Worksheets
If you have an Excel workbook with multiple worksheets, you can also create a CSV file for each worksheet. To do so, you can find all the sheets in a workbook using the Get-ExcelSheetInfo
cmdlet. Once you have the worksheet names, you can then pass those names to the WorksheetName
parameter and also use the sheet name as the name of the CSV file.
Below you can the example code needed.
Conclusion
Using the ImportExcel PowerShell module, you can import, export and manage data in Excel workbooks exactly like you would CSVs without having to install Excel!
In this article, you learned the basics of reading and writing data to an Excel workbook but this just scratches the surface. Using PowerShell and the ImportExcel module, you can create charts, pivot tables and leverage other powerful features of Excel!
More from Adam The Automator & Friends
Ctrl+Select In Excel
When selecting cells and areas in an Excel worksheet, you can select one cell or area with the mouse, then hold the Ctrl key while selecting another cell or area, and the new selection is added to the previous selection. You can select multiple areas at once using this Ctrl+Select sequence.
This is great, until you select one or more cells you didn’t mean to select, or if you just want to deselect something you’ve selected. In Excel worksheets, you can’t use the Ctrl key to unselect something that you’ve selected previously. This is a pain, because you have to start again with your multiple region selection, and hope you don’t mess it up again.
This has been the behavior since Excel 1950 for Univac was introduced.
Ctrl+Select Everywhere Else
In every other application I can think of, when you are selecting objects, you can use Ctrl+Select to add to the collection of selected objects. And if you Ctrl+click on a selected object, it is deselected. This works on objects in PowerPoint, shapes embedded in Word, files and folders displayed in Windows Explorer.
People have grumbled about the inability to deselect a cell in Excel for a long time, and it even has received an entry in Excel UserVoice: Unselecting cells when using Ctrl to select multiple cells.
The New Ctrl+Select Behavior in Excel
Well, the Excel Team was listening, and not long ago they announced that it is possible to Deselect a selection in Excel. According to that announcement, it’s still only available to Insiders, who risk all to get the latest builds with the latest and greatest new features and the occasional “Gotcha!” Read about Office Insiders and What is Office Insider? on the Microsoft Office web site.
Automator App Select Cells Excel
I knew that this suggestion had been made in UserVoice, and I might even have heard that Microsoft was working on it. So one day, when I was tooling away as usual, I incorrectly selected some cells, and thought to myself, “When will they ever let me Ctrl+Select to unselect that stupid cell over there?” And I Ctrl+Selected that stupid cell over there, and it was UNSELECTED! Naturally I didn’t really believe it, so I Ctrl+Selected and Ctrl+Deselected that cell about twelve times.
It’s such a seemingly small change, but it removes a frequent and annoying source of frustration.
How Ctrl+Select and Ctrl+Deselect Work
Automator App Select Cells Excel Download
Suppose I have a range of data like that below left, and for some reason I want to select the header row and the rows with even X values. I start by selecting the header row and the row with X = 0.
Now I hold Ctrl and select the row with X = 2 (below left). That’s how Ctrl+Select works.
Then I hold Ctrl and select the row with X = 4, except I’m clumsy and also select the row with X = 5 (below right).
Ordinarily I would just curse at my poor mouse-eye coordination, and go back to the first selection above. But now I can curse, then hold Ctrl and select the row with X = 5. Or rather, DESELECT the row with X = 5 (below left); the resulting selection is shown below right. That’s how Ctrl+Deselect works.
Now I can Ctrl+Select the row with X = 6 (below left), and do what I want with the selected range, which apparently was shading the cells light gold (below right).
Want More Examples?
So I was playing around to suss out the behavior more fully, and I present a few more examples. They all start with a simple rectangular range selected, C2:G6.
Below left, I’m holding Ctrl while selecting part of the previously selected range, C4:E6. The resulting selection is comprised of the two rectangular areas C2:G3 and F4:G6.
Automator App Select Cells Excel Online
So I learned if the cell you click at the beginning of a Ctrl+Select operation is selected, you will deselect any cells in the range you are currently selecting. I selected B3:F7, starting within the previously selected range at cell F3 (shown below left), so all cells in B3:F7 end up not selected (below right).
If the cell you click at the beginning of a Ctrl+Select operation is not selected, you will select all cells in the range you are currently selecting, and no cells become deselected. I selected B3:F7, starting outside the previously selected range at cell B3 (shown below left), so all cells in B3:F7 end up selected, overlapping the original selection of C2:G6 (below right).
If I then Ctrl+Select D4:E5, which is completely enclosed by the previous selection, that small square region is excised from the selection.
The new selection is easier to see if I then shade the selected cells below.
Finally, it’s impossible to unselect all cells on the active sheet. Well, you can, if you select an object on the sheet, such as a shape, a picture, or a chart. But an active worksheet has an active cell.
Below left, C2:G6 was selected, and I am Ctrl+Selecting the same range, from the bottom left corner to the top right. The new active cell is C6, the first cell of my last Ctrl+Select.
Pretty cool, isn’t it?
A Plug for Excel UserVoice
This is the third UserVoice success story I’ve written about, joining Plot Blank Cells and #N/A in Excel Charts and User Voice Fixes Pivot Table Default Settings. There have been several other UserVoice suggestions implemented by the Excel team, as well as numerous being planned and under review.
UserVoice is a great way to make suggestions about issues or new features in Excel. Don’t just start by making a suggestion, though. Search for your idea, and if it’s already there, vote for it and add a comment. Ideas are grouped by platform (Windows, Mac, Online, etc.) and by topic (Charting, Formatting, Pivot Tables, etc.). Among other criteria, when evaluating user feedback, the team looks for ideas with lots of votes.