Wednesday, November 26, 2008

Reverse a Cell text or Cell value


Hi All,

Today we are know about how to reverse a cell value. Means if you input "RAM" in cell A1 then it returns you "MAR" in other cell.

For doing this we make a custom function. We called the function rvrsstring.

Now, Open a new excel file then open visual basic editor by press Alt+F11 or by the following path,
Tools>macro>visual basic editor.

Now insert a new module, by Insert>module. Now paste following codes.

Public Function rvrsstring(loecell As Range, Optional istext As Boolean) Dim i As Integer Dim strnew As String Dim strold As String strold = Trim(loecell) For i = 1 To Len(strold) strnew = Mid(strold, i, 1) & strnew Next i If istext = False Then rvrsstring = CLng(strnew) Else rvrsstring = strnew End If End Function

Exit from visual basic editor and save the excel file.

Here is a sample:
Enter RAM on cell A1 and you want your result in C1 for this write a formula in cell C1 "=rvrstirng(A1,true)" this formula give you result which is "MAR".


If you want to reverse a long integer value then you can put "=rvrsstring(A1,False)"


If you put a wrong formula it shows you a error.


Here you can see a cLng commands here is a short description about cLng commands in Vba.

In Excel, the CLng function converts a value to a long integer.

The syntax for the CLng function is:

CLng(expression)

Applies To:

  • Excel 2007, Excel 2003, Excel XP, Excel 2000
For more details about CLng commands you can visit the Link
Sample File: Click here

If you want to use this function on your every workbook download the following addins

Addins: Click here

Tuesday, November 25, 2008

Make a non printable Excel file through macro

Hi all,

Today we are discussed about how to make a non printable excel file through vba macro.

Open a new excel sheet and then open Visual basic editor by pressing alt+F11 or you also can open visual basic editor by the following path Tools>Macro>visual basic editor.
Now open Thisworkbook and copy and paste the following code on it.

Private Sub Workbook_Activate()
Dim loectrl As Office.CommandBarControl

'disable print menu
For Each loectrl In Application.CommandBars.FindControls(ID:=4)
loectrl.Enabled = False
Next loectrl

'disable print privew menu
For Each loectrl In Application.CommandBars.FindControls(ID:=109)
loectrl.Enabled = False
Next loectrl

'disable print area menu
For Each loectrl In Application.CommandBars.FindControls(ID:=30255)
loectrl.Enabled = False
Next loectrl

'disable standard print munu
For Each loectrl In Application.CommandBars.FindControls(ID:=2521)
loectrl.Enabled = False
Next loectrl

'disable set print area
For Each loectrl In Application.CommandBars.FindControls(ID:=364)
loectrl.Enabled = False
Next loectrl

' disable add to print area
For Each loectrl In Application.CommandBars.FindControls(ID:=1583)
loectrl.Enabled = False
Next loectrl

'disable exclude from print area
For Each loectrl In Application.CommandBars.FindControls(ID:=1586)
loectrl.Enabled = False
Next loectrl

'disable reset print area
For Each loectrl In Application.CommandBars.FindControls(ID:=2521)
loectrl.Enabled = False
Next loectrl

'disable page setup
For Each loectrl In Application.CommandBars.FindControls(ID:=247)
loectrl.Enabled = False
Next loectrl

End Sub

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub

Private Sub Workbook_Deactivate()
Dim loectrl As Office.CommandBarControl

'enable print menu
For Each loectrl In Application.CommandBars.FindControls(ID:=4)
loectrl.Enabled = True
Next loectrl

'enable print privew menu
For Each loectrl In Application.CommandBars.FindControls(ID:=109)
loectrl.Enabled = True
Next loectrl

'enable print area menu
For Each loectrl In Application.CommandBars.FindControls(ID:=30255)
loectrl.Enabled = True
Next loectrl

'enable standard print munu
For Each loectrl In Application.CommandBars.FindControls(ID:=2521)
loectrl.Enabled = True
Next loectrl

'enable set print area
For Each loectrl In Application.CommandBars.FindControls(ID:=364)
loectrl.Enabled = True
Next loectrl

' enable add to print area
For Each loectrl In Application.CommandBars.FindControls(ID:=1583)
loectrl.Enabled = True
Next loectrl

'enable exclude from print area
For Each loectrl In Application.CommandBars.FindControls(ID:=1586)
loectrl.Enabled = True
Next loectrl

'enable reset print area
For Each loectrl In Application.CommandBars.FindControls(ID:=2521)
loectrl.Enabled = True
Next loectrl

'enable page setup
For Each loectrl In Application.CommandBars.FindControls(ID:=247)
loectrl.Enabled = True
Next loectrl
End Sub

Here you can see a lot of Ids and for write a code like this you must be know about all IDs. For the list of IDs click here

From the following link you can down load a sample file for the same

Download file: Click Here

Thursday, November 20, 2008

Renaming the excel columns tab


Hi Friends,

Today we are discussed about how to renaming the excel columns tab label.

Actually you cant rename a columns tab in excel because excel is a spreadsheet program and you cant change the columns label.
We find a lot of questions from people how to rename a columns tab label in excel like A to "my name" column B to "my address" extra.

But due to excel is a spread sheet program you cant change the column header, for changing the columns header you must be used a database program like Microsoft Access.

But by hiding the columns header from excel you can use a excel sheets columns name you want.
For doing this you must be use the row 1 for your heading.

For hiding the columns in excel spread sheet do the following.
Go To: Tool>Option and then select view tab. Then remove the tick from the Row & Column Header. After pressing ok button you see that the row and column header are vanished from the sheet. Now in row 1 and column A you put the name which you want in this sheet.



After hide the row and columns header you put your formula like same as you put in previous.

you also can show a example of the sheet here.

Download Here

Subscribe Now: From your browser

Search:

Learn Office Excel