This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function cnn_str(DB As String) | |
Dim cnnStr As String | |
Select Case DB | |
Case "AccessDB" ''' | |
''("Provider = Microsoft.ACE.OLEDB.12.0; data source=" & "C:\CodeMiner\CodeMinerDb.accdb") | |
cnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;" & _ | |
"Data Source=" & "C:\Users\Documents\DqExplorer" & "\" & "ppsdb.accdb" | |
Case "SqlExpress" | |
cnnStr = "driver={SQL Server};server=mynotebook\SQLEXPRESS;" & _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub sqlExplorer() | |
Dim wb As New Workbook | |
Dim ws As New Worksheet | |
Set wb = ActiveWorkbook ''ThisWorkbook | |
Set ws = wb.Sheets("SqlExplorer") | |
Dim qry_text As Variant | |
Dim rngHeader As range | |
Dim rngResult As range | |
qry_text = range("qry_text").Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub read_word() | |
Dim wa As Word.Application | |
Dim wd As Word.Document | |
Dim wdtable As Word.Table | |
Dim wdFileName As Variant | |
Dim TableNo As Integer 'number of tables in Word doc | |
Dim iTable As Integer 'table number index | |
Dim iRow As Long 'row index in Excel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub arrays_declare() | |
'방법 1 : Dim 사용 | |
Dim arr1() 'Size 없이 선언 | |
'방법 2 : Size를 지정하여 선언 | |
Dim arr2(5) '사이트 5를 지정 | |
'방법 3 : 'Array' 파라메터 사용 | |
Dim arr3 | |
arr3 = Array("사과","오렌지","포도") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub show_datetime() | |
Dim adate As Variant | |
adate = Date | |
Debug.Print adate ''2019-01-09 | |
Debug.Print Year(adate) ''2019 | |
Debug.Print Month(adate) ''1 | |
Debug.Print Day(adate) ''9 | |
Debug.Print DateAdd("yyyy", 1, adate) ''2020-01-09 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub show_strings() | |
Dim str As String | |
str = "Microsoft VBA" | |
''1. InStr: 문자가 나타난 첫번째 위치 | |
Debug.Print InStr(str, "VBA") ''Result= 11 | |
''2. InStrRev: 역순으로 문자가 나타난 첫번째 위치 | |
Debug.Print InStrRev(str, "VBA") ''Result= 11 | |
''3. LCase: 소문자로 변경 | |
Debug.Print LCase(str) ''Result= microsoft vba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function fnc_add(width As Integer, height As Integer) | |
''함수 예제 | |
Dim 가로 As Integer | |
Dim 세로 As Integer | |
Dim 면적 As Integer | |
가로 = width | |
세로 = height | |
면적 = 가로 * 세로 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub prc_add() | |
''프로시져 예제 | |
Dim 가로 As Integer | |
Dim 세로 As Integer | |
Dim 면적 As Integer | |
가로 = 3 | |
세로 = 4 | |
면적 = 가로 * 세로 |