Upcoming SlideShare
×

# Excelマクロはじめの一歩

619 views

Published on

Excel Macro First Step

Published in: Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
619
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
12
0
Likes
1
Embeds 0
No embeds

No notes for slide
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• \n
• ### Excelマクロはじめの一歩

1. 1. Excel 2012/01/23
2. 2. :^(d{3}[357])(.*?) (.*?) (([0-9a-zA-Z ]+?))(.* )\$12 3 (1_4_3)5S([0-9]{3}(3|5|7))>(.*) (.*) ((.*))(.*)1>2 3 (1_4_3)5T^([0-9]{3}[357])(..*? )(..*)( .*()([0-9a-zA-Z ]*)().* )\$\$1\$2\$3\$4\$1_\$5_\$3\$6
3. 3. [ ]
4. 4. [ ]
5. 5. [ ]=> /[ ]=>
6. 6. Alt+F11 VBA [ ] Module1( Mac Win[ ] [???????] )
7. 7. Sub Macro1() Macro1 Macro Range("C3").Select ActiveCell.FormulaR1C1 = "foo" Columns("D:D").Select Selection.Insert _ Shift:=xlToRight,CopyOrigin:=xlFormatFromLeftOrAbove Range("A1").Select Cells.Find(What:="foo", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False, _ MatchByte:=False, SearchFormat:=False).ActivateEnd Sub 1. C3 ”foo” 2. D 3. “foo”
8. 8. Sub (<arg *optional>) < >End Sub( ) : Sub Function VBA xls =Foo(A1) Function “Foo”
9. 9. http://www.asahi-net.or.jp/~ef2o-inue/vba_k/sub04_020.html
10. 10. VBADim i As IntegerDim columnInternal As StringDim columnInvoicedAmt As DoubleDim rowNum As BooleanDim tmp As VariantDim < > As < > Option Explicithttp://www.asahi-net.or.jp/~ef2o-inue/vba_k/sub04_040.htmlhttp://www.asahi-net.or.jp/~ef2o-inue/vba_k/sub04_050_06.html
11. 11. ( ) Integer String Long Date Single Object Double Variant Currency Booleanhttp://excelvba.pc-users.net/fol5/5_2.html
12. 12. =a = 100 a 100 a ← 100 a 100 i = i + 1 i i 1 :i = 2 i = i + 1 i = 3http://home.att.ne.jp/zeta/gen/excel/c04p22.htm
13. 13. If ( )
14. 14. ( )=: =:+: <>:-: >:*: >=:/: <:mod: <=:^:
15. 15. if(if )If 1 Then 1ElseIf 2 Then 2Else 1 2End If*ElseIf Elsehttp://excelvba.pc-users.net/index.html 6http://excelvba.pc-users.net/fol6/6_1.htmlhttp://www.asahi-net.or.jp/~ef2o-inue/vba_k/sub04_050_02.html
16. 16. :If Cells(1,1).Value = 1 Then Cells(1,2).Value = “Foo”ElseIf Cells(1,1).Value = 2 Then Cells(1,2).Value = “bar”Else Cells(1,2).Value = “hoge”End If Cells(1,1) ( A1) -1 Cells(1,2) ( B1) “Foo”2 Cells(1,2) ( B1) “bar” Cells(1,2) ( B1) “hoge”ElseIf( )
17. 17. For Next( if )For = ToNext For i jhttp://excelvba.pc-users.net/fol6/6_3.htmlhttp://www.sigoto.co.jp/excel/statement/state09.htm(For each Next )
18. 18. :Dim i As IntegerFor i = 1 To 10 Cells(i, 1).Value = i * 10 i = i + 1Next i 1 i( )For i = 1 To 10 Next i 1 10Cells(i, 1).Value = i * 10 Cells(i, 1) i*10i = i + 1 i 1 ” i+ 1”
19. 19. ( 2:30...)
20. 20. xciConvert.xlsmAlt+F11 VBA Before.xls After.xls
21. 21. Client Project Number ClientInternal % % (+ )Vendor % (+ )Invoiced Amt Project Total Invoiced Amount 0Invoiced AmtGMClient Name BU Name CompDate BDMGM% :
22. 22. 3
23. 23. /
24. 24. Lefthttp://officetanaka.net/excel/vba/function/Left.htmInStrhttp://officetanaka.net/excel/vba/function/InStr.htmOffsethttp://officetanaka.net/excel/function/function/offset.htmCSnghttp://officetanaka.net/excel/vba/function/CSng.htmhttp://officetanaka.net/excel/vba/function/index.htm