Excel VBA FAQ 2
[] [1] [2] [3] [H] [gu]
IuWFNg
IuWFNgH
- IuWFNguijvB[NV[gR}h{^IuWFNgB
IuWFNgf[^R}hBR}hVBAu\bhvuvpeBvBvOIuWFNgAuXXXXIuWFNgXXXX\bhsvuXXXXIuWFNgXXXXvpeBlvB
ASheet1[NV[gIAuSheet1IuWFNgSelect\bhsvBSheet1OXAuSheet1IuWFNgNamevpeBlvB
\bhvpeBH
NXCX^XH
- NXIuWFNgB[NV[gNXR}h{^NXNXB
CX^XIuWFNguvBIuWFNgCX^XIuWFNgNX`iv}jB
AExcel[NV[gNX`ASheet1CX^XB
IuWFNgQH
- IuWFNgCX^XIBvOAIuWFNgQgIuWFNgCX^XwBAIIAvOAu12IuWFNgvB
AIuWFNgQAA\bhvpeBgBAA1:C3ZIuWFNgQ Range("A1:C3") BRangevpeBiExcel5.0/95Range\bhjIuWFNgApplicationIuWFNgvpeBAANeBuV[gAwRangeIuWFNgQB
IuWFNgQAgAi[AIuWFNgQvpeB\bhgpBIuWFNgQi[SetXe[gggB
AANeBuV[gA1:C3RangeIuWFNgQobji[ASet obj = Range("A1:C3") BARange("A1:C3").Clear Aobj.ClearB
RNVH
- IuWFNgCX^XWB
AubN[NV[gWu[NV[gRNVvuWorksheetsRNVIuWFNgvBRNVIuWFNgBRNVOIuWFNgO`B
RNVIuWFNgQgBAANeBuubNSheet1[NV[gIuWFNgQAuANeBuubN[NV[gRNVASheet1OV[gvwB
R[h ActiveWorkbook.Worksheets.Item("Sheet1") B
uActiveWorkbook.WorksheetsvuANeBuubN[NV[gRNVvIuWFNgQBu.Item("Sheet1")vuRNVASheet1OV[gvIuWFNgQB
ItemvpeBiExcel5.0/95Item\bhjAWorksheetsRNVIuWFNgvpeBAAActiveWorkbook.Worksheets("Sheet1") B
ItemOCfbNXwBA2[NV[gwAActiveWorkbook.Worksheets(2) B
RNVKCountvpeBBANeBuubN[NV[gAActiveWorkbook.Worksheets.Count B
uRange("A1")vuRangevuRangeIuWFNgvH
- BRangevpeBiExcel5.0/95Range\bhjBRangeIuWFNgW[OAIuWFNgB
RangevpeBApplicationIuWFNgAWorksheetIuWFNgARangeIuWFNgvpeBBRangeIuWFNgQ_AIuWFN/h3>
- BApplicationvpeBBApplicationIuWFNgW[OAIuWFNgB
ApplicationvpeBIuWFNgAIuWFNgAvP[VIuWFNgQBExcelVBAIuWFNgAApplicationIuWFNgiExcelVBAExceljApplicationvpeBBApplicationIuWFNgApplicationvpeBApplicationIuWFNgQB
Sheet1UserForm1NXHCX^XH(Excel97)
- Sheet1NXAUserForm1NXASheet1Sheet1NXCX^XAUserForm1UserForm1NXCX^XB
[NV[gAASheet1NXANXSheet1CX^XIBSheet1NXCX^XB
UserForm1lA[UtH[AUserForm1CX^XOABA}Ns[hiLoadjB[hLoadXe[gggAgAUserForm1OgI[hBUserForm1NXCX^XB
Excel97[NV[gVBvWFNgB[NV[gAAXvWFNgXAvWFNgSB
s
Personal.xlsilp}NubNjH
- }NL^uL^vIvVAI/p>
}NsAhDH
G[}NIH
Sub Sample_SetSheetName() Dim sName As String sName = "Wv" 'G[gbv 'G[ErrorHandlerxWv On Error GoTo ErrorHandler 'V[gX ActiveSheet.Name = sName 'G[gbv On Error GoTo 0 'G[sA 'KExit Sub Exit Sub 'G[x ErrorHandler: 'G[bZ[W\ MsgBox sName & " B", vbExclamation Exit Sub End Sub
Worksheet_ChangevV[WZlXvV[Ws(Excel97)
Private Sub Worksheet_Change(ByVal Target As Excel.Range) '() On Error GoTo ErrorHandler Application.EnableEvents = False Target.Value = 0 Application.EnableEvents = True Exit Sub ErrorHandler: MsgBox Error(Err), vbExclamation Application.EnableEvents = True End Sub
ExceA2:A100")) Application.WorksheetFunction.Match()G[(Excel97)
WorksheetFunctiongG[gbvKvBExcel97Application.Match()]Variant^G[lBExcel97oOdlmBWorksheetFunctiongB
FZJEg[U[`AZFXvZB
[U[`[NV[gZlH
B[U[`[NV[gAZlOBgp\bhvpeBB
OtGIF"C:\My Documents\Chart1.gif"
vO~O
コンピュータのパーツは何ですかliJ}j
Array}NgH
Sheets(Array("Sheet1", "Sheet2")).SelectAIV[gEnd Sub
SendKeys "^c" sRs[
- ExcelV[gL[MAL[M_sAExcelA}NsIB
[U[tH[Rg[zgH
[U[tH[[X]{^H
- [X]{^AQueryCloseCxggpA[U[N[YLZB
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End If End Sub
y[Wwb_[tH
Sub Sample_SetPageHeader() With ActiveSheet.PageSetup .LeftHeader = _ ActiveWorkbook.FullName & _ " &A " & _ Format$(Date, "m""""d""(""aaa"")""") & _ " &T" .CenterHeader = "" .RightHeader = "" .LeftFooter = "" .CenterFooter = "&P / &N" .RightFooter = "" End With End Sub
y[WmH
Sub Test_PageCount() Dim iPageCount As Integer Sheets("Sheet1").Select iPageCount = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)") MsgBox CStr(iPageCount) End Sub
}CN\tgT|[gZpHPageBreaksVPageBreaks/p>
_CAO{bNX
sOmFbZ[W\H
Sub Sample_Alert() Dim iRet As Long '_CAO{bNX\A{^ iRet = MsgBox("sB", vbOKCancel Or vbExclamation) 'LZ{^I If iRet = vbCancel Then MsgBox "LZB", vbInformation Exit Sub End If ' 'IbZ[W\ MsgBox "sB", vbInformation End Sub
}NZwH
- InputBox\bhTypep[^8wZBRangeIuWFNgSetXe[gggKvBALZKG[AG[gbvsKvB
Sub Sample_InputRange() Dim oRange As Range Set oRange = Nothing On Error Resume Next Set oRange = Application.InputBox( _ prompt:="ZIB", _ Title:="ZI", _ Type:=8) On Error GoTo 0 If oRange Is Nothing Then MsgBox "LZB", vbInformation Exit Sub Else MsgBox oRange.Address(external:=True) & _ " IB", vbInformation End If End Sub
br/>GetOpenFilenamelA_ fileFilter:=StrConv("Microsoft Excel IB
AExcel@\[UC^tF[X@\A@@\BAhCubN@ BAExcel97Excel5.0/95W[BlAExcel97o[W\B
Excel97o[WAbvvAExcel95}NgH
- gAgBdlX}CN\tgWeby[Wi}CN\tgT|[gZpjBdlX}CN\tgB
lAExcel97}No[WB
[]
0 コメント:
コメントを投稿