You are on page 1of 13

click and get file names as list on seprate sheets

just give file extension and file folder location


Auto Run [24/12/2001] (back to top)
Making your macros run automatically when opening your workbook. You can either use the Auto Open method or the
Workbook Open method. These macros will display the message "Hello" when you open the workbook.

Sub Auto_Open()
Msgbox "Hello ' I am in Module1' "
End Sub

when u open this workbook this macro will run

for more excel help go to


http://www.angelfire.com/biz7/julian_s/julian/julians_macros.htm#A
use the Auto Open method or the
he workbook.
This code would be located in the module. However if you use the second method, the code must be in the workbook
(double click "This Workbook" in the explorer window). Click on the drop down list (that says General) and select Workbook.
Click on the drop down list (that says declarations) and select Open.

Private Sub Workbook_Open()


Msgbox "Hello 'I am in this workbook'"
End Sub

when u open this workbook this macro will run


he code must be in the workbook
ays General) and select Workbook.
Current Cell Content [24/12/2001] (back to top)

Sometimes we need to know what the cell contains ie dates, text or formulas before taking a course of action. In this ex
message box is displayed. Replace this with a macro should you require another course of action.

Value Result Sub ContentChk()


Blank cell If ActiveCell = "" Then
Ab© Text MsgBox "Blank cell" 'replace this line with your macro
3 Formula Else
8/23/2009 Date If Application.IsText(ActiveCell) = True Then
MsgBox "Text" 'replace this line with your macro
Else
If ActiveCell.HasFormula Then
MsgBox "formula" 'replace this line with your macro
Else
End If
If IsDate(ActiveCell.Value) = True Then
first select yellow cells MsgBox "date" 'replace this line with your macro
Else
End If
End If
End If
End Sub
ourse of action. In this example a
Current Cell Position
Sometimes we need to know the current cell position. This would do the trick.

select any cell and know which cell is selected

6,1 6,2 Sub MyPosition()


7,1 7,2 myRow = ActiveCell.Row
8,1 8,2 myCol = ActiveCell.Column
9,1 9,2 Msgbox myRow & "," & myCol
10,1 10,2 End Sub
Click reset to enable select buttos

sr name gujarati hindi english maths science social study total


1 nidhi 54 43 48 58 48 46 297
2 sejal 48 46 54 46 47 58 299
3 rucha 54 58 58 54 58 46 328
4 tanvi 58 49 46 58 54 58 323
5 anokhi 65 44 58 46 48 46 307

Select

Select Sub DeleteNames()


Dim NameX As Name
Select For Each NameX In Names
ActiveWorkbook.Names(NameX.Name).Delete
Select Next NameX
End Sub
Select

Select
Goto (a range)
Select To specify a macro to go to a specific range you can use the Goto method.
Here I have already named a range in my worksheet called "Sales". You
Select may also use an alternative method ie the Range select method. Naming a
range in excel is recommended rather than specifying an absolute cell
reference.

Sub GoHere()
Application.Goto Reference:="Sales" OR Range("Sales").Select
End Sub
i have use following code

Sub Goname()
Application.Goto reference:="name"
End Sub

Sub gogujarati()
Application.Goto reference:="gujarati"
End Sub

Sub gohindi()
Application.Goto reference:="hindi"
End Sub

Sub goenglish()
Application.Goto reference:="english"
End Sub

Sub gomaths()
Range("maths").Select
End Sub

Sub goscience()
Range("science").Select
End Sub

Sub gosocial_study()
Sub goenglish()
Application.Goto reference:="english"
End Sub

Sub gomaths()
Range("maths").Select
End Sub

Sub goscience()
Range("science").Select
End Sub

Sub gosocial_study()
Range("social_study").Select
End Sub

Sub gototal()
Range("total").Select
End Sub
n use the Goto method.
t called "Sales". You
elect method. Naming a
ing an absolute cell

nge("Sales").Select
Function MyName() As String
MyName = ThisWorkbook.Name
End Function

Function MyFullName() As String


MyFullName = ThisWorkbook.FullName
End Function

Function SheetName(rAnyCell)
Application.Volatile
SheetName = rAnyCell.Parent.Name
End Function

Formula Result
=MyName() #VALUE!
=MyFullName() #VALUE!
=CELL("filename") 'file:///opt/scribd/conversion/tmp/scratch8/21572660.xls'#$Sheet15
=sheetname(A1) #VALUE!

Sheet1

You might also like