Skip to main content

Posts

Showing posts with the label VBA

Excel VBA find last row with data

In Excel, ctrl + end will go to the last cell with a value. But this will be tricky if you have deleted the last row with a value or has deleted its contents on the cell. Since it will be recoded as the last cell that has a value or the user has inputted or type on that specific cell.   And Excel will still remember it as the last type cell with value. Pressing ctrl + end will still go there, thus provide the wrong result. However, to prevent this from happening you need to close the workbook and open it again. Then pressing ctrl + end will show the last row with value. But while the worksheet is active any last typed cell even though its content or deleted will be considered as the last row. Getting the last row with data even without closing the workbook can be done via this simple VBA code below. One caveat though, this will only search for the defined row within the VBA code and the number of rows to be checked has to be defined on the code also. So, type a numbe...

Use PowerShell in Excel VBA

VBA in Excel is very helpful since it can run things without any human intervention, or technically it can run task and automate things and just get the result. VBA coupled with PowerShell can even be more interesting. Of course, there is always some drawback or pros and cons. Bad actor can take advantage of VBA and PowerShell to run malicious software on user’s computer. For most users who are not aware or doesn’t believe that VBA and PowerShell can be used to steal data, one common reaction is; Is it possible? Or you are just trying to exaggerate and scare people? As the odds say, to see is to believe. Or to see it in action is one thing and trying to educate users is another thing. Cyber Security is a task that everyone should be a part of, a chain is useless if one its link is weak. Which is basically, true in digital world. The company may spend thousands of moneys on Firewall, Anti-Virus and other devices or software to thwart attack but just a simple click on a Phishin...

Type equal sign in Excel Office 365 without evaluating

How to type equal sign "=" in Excel without evaluating? Typing equal sign in Excel will trigger Excel to evaluate the contents or the formula that is being typed. But how to type equal sign plus the contents without evaluating the formula? Or how to display a formula in a cell using Excel? In VBA, Excel Macro, VBscript and VB.Net; to put comments or remarks on the code is to use single quote. A single quote tells the engine that whatever that follows from the quote is a string and not a command and should not be evaluated. In this way, you can type anything after the single quote “ ‘ “. So, this goes the same way in the Excel interface. If you want just to show the formula for remarks or whatever purposes but don’t want Excel to evaluate the contents, then just type a single quote before the equal sign or the formula. Example: ‘=1+1 Excel will just display =1+1 It will be treated as a literal string. Of course, without the single quote ...

PowerShell check sound devices

PowerShell code below will list the names of the sound devices and its status on the system. The status might show OK, I believe this refers to the driver installation but if some settings are misconfigured that will be another issue. Here’s the code: Get-WmiObject -Query "Select * from Win32_sounddevice" -Namespace 'Root\CIMV2' Sample output: Manufacturer          Name                           Status StatusInfo ------------          ----                           ------ ---------- Intel(R) Corporation Intel(R) Display Audio         OK           ...

PowerShell get Printer Name and Driver path

Descriptive Printer name is quite useful especially if managing quite a few printers on a network. Knowing the driver path of the printers is also useful, the file can be copied and can be used to install on another computer if necessary. Here’s the PowerShell code: Get-WmiObject -Query "Select DriverPath, Name from Win32_printerdriver" -Namespace 'Root\CIMV2' | Select Name , DriverPath | ft -wrap Sample Output: Cheers..till next time. :) ================================ Free Android Apps: Click  links below to find out more: Excel Keyboard guide: https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide Heaven's Dew Fall  Prayer app for Android : https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer Catholic Rosary Guide  for Android: http...

PowerShell GUI with buttons, textbox and combobox

GUI makes life easier, but of course command line has a power of its own. How to add a form in PowerShell with Buttons, TextBox and ComboBox? Adding GUI forms in PowerShell must be done manually by code. It’s not that hard, you just need to love PowerShell and see what it can do to automate IT administration and makes your life easier. Anyway, code below introduces how to add GUI to PowerShell and it also illustrates how to make use of those GUI buttons and send a command to remote computers. Code to add buttons, textbox and combobox in PowerShell, and how to execute a command after the button is clicked. #initialize the main form $form = new-object Windows.forms.form $form . text = "Server Selection Form" $form . minimumSize = New-Object System.Drawing.Size ( 600 , 300 ) $form . maximumSize = New-Object System.Drawing.Size ( 600 , 300 ) #add a button to the form $button = new-object windows.forms.button $button . text...