excel
Excel Tip - How to extract first 20 characters from the string
Submitted by ravisagar on Mon, 11/29/2010 - 06:28Today I was working on excel (yeah yeah I do work sometimes), I wanted to extract the first 20 characters from the string. I forgot the function name, I did a quick google search and found out the solutions.
left(A1,20) is the function to extract first 20 characters from A1 cell!!
Simple.
PS - I am writing this blog because I may require to do so in future, may be 10 years. So I will check back my blog.
- ravisagar's blog
- Add new comment
- 1536 reads
How to change the background color of entire row in Excel using VBA code - Conditional
Submitted by ravisagar on Sun, 02/10/2008 - 16:42My friend Vinod gave me a problem to change the background color of entire row to Red and also to change the font to bold. It seems to be an easy task but there are two constraints.
1. He want to do this only for those lines which has font color of red.
2. There are 2500 entries in the excel.
Now if you have plenty of time then you can do this task in some hundred years :) but I am a Lazy guy so I wrote this little Macro code.
Private Sub Workbook_Open()
For Each cell In Worksheets("sheet1").Range(Worksheets("sheet1").Range("A1"), _
Worksheets("sheet1").Range("A1").End(xlDown))
If cell.Font.Color = RGB(255, 0, 0) Then
cell.Font.Color = RGB(0, 0, 0)
cell.EntireRow.Font.Bold = True
cell.EntireRow.Interior.Color = RGB(255, 0, 0)
End If
Next cell
End Sub
You can write this code either in the Open Event of the Workbook or write a Module for it.
For Each cell In Worksheets("sheet1").Range(Worksheets("sheet1").Range("A1"), Worksheets("sheet1").Range("A1").End(xlDown))
This code simply defines the range starting from cell A1 till the bottom most cell which has any data.
End(xlDown))
This is similar to pressing Ctrl + Down Arrow
cell.Font.Color = RGB(0, 0, 0)
This code changes the font color of the cell content
cell.EntireRow.Font.Bold = True
This code changes the font to Bold
cell.EntireRow.Interior.Color = RGB(255, 0, 0)
This code fills the cell with Red color
- ravisagar's blog
- 4 comments
- 23458 reads
About
Welcome to my site or weblog or whatever you want to call it. I don't know why I created this site. I guess I like flaunting. I made this site hoping to write blogs and update it regularly. I don't get much time to write blog rather I would say that I am too lazy person. I do write about Open Source technologies and other things. Hope you find something useful on my site. Even if you don't just drop me a line. I would love to know more about you.
You can check the photos that I clicked randomly here http://www.flickr.com/photos/ravisagar
I am also an Admin for Linux Indya, site to promote Linux and a community site for Guru Gobind Indraprastha University.
- Read more
- 7075 reads




