tecivo BLOG

My IT notes, 'How To...' guides, Microsoft, SharePoint, Citrix, AppSense, Apple, technology & gadgets and more!

Tag: FIND (page 1 of 2)

Excel Tips…How to display the Worksheet name in a cell

I was wondering this week how to automatically link the contents of a cell to the worksheet name and found that you can use the CELL function.

Rather than enter the text independently into the both cell and worksheet name, you can use CELL to obtain workbook and worksheet information then FIND to return just the worksheet name.

The CELL function provides detail associated with the defined cell including file name and worksheet name

A1 is used as it is the first cell in the worksheet.

A < A function >
1 folderpath\[filename]worksheetname =CELL(“filename”,A1)

 

So if I have a worksheet called ‘Server List – Data Centre 1

A < A function >
1 folderpath\[filename]Server List – Data Centre 1 =CELL(“filename”,A1)

 

Add FIND to locate the ] and only return data after – resulting in just the worksheet name:

A < A function >
1 Server List – Data Centre 1 =MID(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))+1,255)

+1 means to start with the first character after the ], the 255 references the last character to return:

A < A function >
1 Server List =MID(CELL(“filename”,A1),FIND(“]”,CELL(“filename”,A1))+1,11)

Notes:

  • The formula will not return valid results if you use it in a new workbook that hasn’t been saved. You need to save the workbook, close it then reopen so the information can be returned by the CELL function successfully.
  • It also will not work properly if the workbook or worksheet name contains the right bracket ‘]

 

Thanks to Allen Wyatt’s blog for the help: http://excelribbon.tips.net/T011419_Getting_the_Name_of_the_Worksheet_Into_a_Cell.html

Excel Tips…Using LEFT, MID and FIND to return initials from a name

If you have someone’s name in a cell and want to automatically extract initials, you can use LEFT, MID and FIND.

As always when working with text cells, you can wrap with UPPER, LOWER or PROPER.

A B < B function >
1 Joe Bloggs JB =LEFT(A1)&MID(A1,FIND(” “,A1)+1,1)
2 joe bloggs JB =UPPER(LEFT(A2)&MID(A2,FIND(” “,A2)+1,1))

 

I also found online  a funtion to manage three names – seems long so I imagine there is an easier way to do it, but it works:

A B < B function >
1 Joe John Bloggs JJB =IF(LEN(A1)-LEN(SUBSTITUTE(A1,” “,””))=0,LEFT(A1,1),IF(LEN(A1)-LEN(SUBSTITUTE(A1,” “,””))=1,LEFT(A1,1)&MID(A1,FIND(” “,A1)+1,1),LEFT(A1,1)&MID(A1,FIND(” “,A1)+1,1)&MID(A1,FIND(” “,A1,FIND(” “,A1)+1)+1,1)))

 

Excel Tips…Using LEFT, RIGHT, MID & FIND to remove unwanted characters e.g. remove FQDN to leave hostname, or IP octets

Introduction

LEFT, RIGHT, MID and FIND are useful Excel functions to help you extract specific parts of text or numbers from a cell.

The examples below show how to extract a server name from Fully Qualified Domain Domain, how to extract server names from LDAP attribute name, how to extract specific octets from an IP address, how to extract text from inside specific characters and how to trim specific characters from the start or end on a cell contents.

Use LEFT to extract server name from FQDN

If wanted add UPPER to enforce case

A B < B function >
1 servername servername =LEFT(A1,(FIND(“.”,A1&”.”)-1))
2 servername SERVERNAME =UPPER(LEFT(A2,(FIND(“.”,A2&”.”)-1)))

Use LEFT and SUBSTITUTE extract specific octets from IP address

A B < B function >
1 192.168.1.1 192 =LEFT(A1,FIND(“~”,SUBSTITUTE(A1,”.”,”~”,1))-1)
2 192.168.1.1 192.168 =LEFT(A2,FIND(“~”,SUBSTITUTE(A2,”.”,”~”,2))-1)
3 192.168.1.1 192.168.1 =LEFT(A3,FIND(“~”,SUBSTITUTE(A3,”.”,”~”,3))-1)
4 0 #VALUE =LEFT(A4,FIND(“~”,SUBSTITUTE(A4,”.”,”~”,3))-1)

If the source cell value is 0 Excel will return #VALUE

To allow for this use IF to return 0

A B < B function >
1 192.168.1.1 192 =IF(A1<>0,(LEFT(A1,FIND(“~”,SUBSTITUTE(A1,”.”,”~”,1))-1)),”0″)
2 192.168.1.1 192.168 =IF(A2<>0,(LEFT(A2,FIND(“~”,SUBSTITUTE(A2,”.”,”~”,2))-1)),”0″)
3 192.168.1.1 192.168.1 =IF(A3<>0,(LEFT(A3,FIND(“~”,SUBSTITUTE(A3,”.”,”~”,3))-1)),”0″)
4 0 0 =IF(A4<>0,(LEFT(A4,FIND(“~”,SUBSTITUTE(A4,”.”,”~”,3))-1)),”0″)

Use MID and FIND to extract server name from LDAP attribute

MID is used to identify starting character of the server name – in this case the 4th

FIND is used to find the commas which is used to determine the end of the server name

A B < B function >
1 CN=servername,OU=Member Servers,DC=tecivo,DC=com servername =MID(A1,4,FIND(“,”,A1)-4)

Use MID and FIND to extract text inside of brackets

A B < B function >
1 Integrated Lights-Out 3 (iLO 3) iLO 3 =MID(A1,FIND(“(“,A1)+1,FIND(“)”,A1)-FIND(“(“,A1)-1)

Use LEFT and LEN to remove character(s) from end of text

e.g. to remove R from end of hostname of server located in cell A1
-1 determines how many characters to remove

A B < B function >
1 servernameR servername =LEFT(A1,LEN(A1)-1)

Use RIGHT, LEFT and LEN Remove specific number of characters from a text entry – left side or right side

Remove a single character from the start of text – e.g. Q from Q2969339
-1 determines how many characters to remove

A B < B function >
1 Q2969339 2969339 =RIGHT(A1,LEN(B=A1)-1)

To do same but remove two characters from the right side of text – e.g. remove the Q and the R from 2969339QR

A B < B function >
1 2969339QR 2969339 =LEFT(A1,LEN(A1)-2)

Also see

 

Older posts

© 2017 tecivo BLOG

Theme by Anders NorenUp ↑