You are on page 1of 6

Excel VBA

2006-09-18 21:53 2181 (0)


excelvba integer string

VB VBA VB

Dim
Dim a as integer ' a
Dim a ' a
Dim a as string ' a
Dim a as currency ,b as currency ,c as currency ' a,b,c
......
ByteBooleanIntegerLongCurrencySingleDoubleDecimalDateString
String * lengthObjectVariant

Option Explicit

Const

'
Private
Const My = 456

' Public
Public Const MyString = "HELP"

' Private Integer


Private Const MyInt As Integer = 5

'
Const MyStr = "Hello", MyDouble As Double = 3.4567

EXCEL97

Sub My_Select
Selection.CurrentRegion.Select
End sub


sub my_trim
msgbox Trim(ActiveCell.Value)
end sub

sub my_offset
ActiveCell.Offset(0, 1).Select'
ActiveCell.Offset(0, -1).Select'
ActiveCell.Offset(1 , 0).Select'
ActiveCell.Offset(-1 , 0).Select'
end sub

sub my_offset on error resume next

sub
end sub
!

ActiveCell.Value = ""

""
Range("a1").value="hello"

sheet1 sheet2 ""


1.
sheets("sheet2").select
range("a1").value="hello"

2.
Sheets("sheet1").Range("a1").Value = "hello"


1.sheet2
HELLO"A1
2.sheet2 HELLO" sheet2 A1

' SHEET1
sheets("sheet1").Visible=False

' SHEET1
sheets("sheet1").Visible=True

EXCEL SHEET

Dim my As Worksheet
For Each my In Worksheets
my.PrintPreview
Next my

msgbox ActiveCell.Address

msgbox date & chr(13) & time

ActiveSheet.Protect

ActiveSheet.Unprotect

"liu"
ActiveSheet.Name = "liu"

AppActivate (Shell("C:/WINDOWS/CALC.EXE"))

Worksheets.Add

activesheet.delete

Workbooks.Open FileName:="C:/My Documents/Book2.xls"

ActiveWindow.Close

Selection.HorizontalAlignment = xlLeft

Selection.HorizontalAlignment = xlCenter

Selection.HorizontalAlignment = xlRight

Selection.Style = "Percent"

Selection.Font.Bold = True

Selection.Font.Italic = True

20
With Selection.Font
.Name = ""
.Size = 20
End With

With

With
.
End With

ActiveCell.Clear '

MsgBox Selection.Rows.Count

MsgBox Selection.Columns.Count

Selection.Address


ON ERROR RESUME NEXT

on error goto err_handle


'
err_handle: '
'

kill "c:/1.txt"

Application.StatusBar = ": " & Time

Application.StatusBar = false

Application.Run macro:="text"

a1
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

Dim MyDate, MyDay


MyDate = #12/12/69#
MyDay = Day(MyDate)

Dim MyDate, MyYear


MyDate = Date
MyYear = Year(MyDate)
MsgBox MyYear

inputbox<>
XX=InputBox ("Enter number of months to add")

Dim kk As String

kk = Application.GetOpenFilename("EXCEL (*.XLS), *.XLS", Title:=" EXCEL ")


msgbox kk

zoom
Application.Dialogs(xlDialogZoom).Show

Application.Dialogs(xlDialogActiveCellFont).Show

Dim kk As String
kk = Application.GetSaveAsFilename("excel (*.xls), *.xls")
Workbooks.Open kk

You might also like