Skip to main content


Showing posts from March, 2015

Excel VBA replace first or last character

Excel VBA code below will replace the first or last character of the cell value.

Use a test workbook with dummy data, to test the VBA code.

Works fine on Excel 2010.

Sub replaceChar()
'Replace Last Character

Dim i, ilength As Integer
Dim strCellValue, yCutString, zValue As String
Dim iRow, myColumn As Long

'specify the column where the values will be changed
myColumn = 2

'get the last row
iRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row

For i = 1 To iRow
On Error Resume Next

strCellValue = Cells(i, myColumn).Value
ilength = Len(strCellValue) - 1

'left - will replace last character on the string
yCutString = Left(strCellValue, ilength)

' LastChar is the string that will be added to the end of the cell value
'Replace this with any desired value
zValue = yCutString + "LastChar"

'Display the value of the processed string
'press ctrl+break to stop the loop
MsgBox zValue

'uncomment this line to replace the value with the processed string

Netstat to check listening ports

To check listening ports on windows, netstat is a tool that is quite handy.

And not only windows uses this tool, Linux system use this tool also. In windows to check listening ports and the application that uses the port type:

netstat -abn

The command needs to run at an elevated command prompt.

netstat -ano  is able to check listening and established ports.

Check out this link on how to open an elevated command prompt:

The command will list the local address the foreign address or the public ip and the state.

Example output will be like this:


In Linux this command would come handy:

netstat -tulpn

It will list the udp, tcp ports that are listening and also the daemon service listening or using the port.

Check out link below how to use netstat and Powershell to check open ports in Windows.…

How to lock computer after inactivity