201409.xlsm


Option Base 0

Sub temp()
    Dim i, intrv As Integer
    Dim indt As String
    Dim base_date As Date
    
    Dim edt() As Variant
    Dim yymm() As Variant
    Dim yyyymm() As Variant
    
    Dim edtf() As Variant
    Dim yymmf() As Variant
    Dim yyyymmf() As Variant

    
    '숫자로 된 기준일(20140101)을 받아서 스트링으로 저장
    indt = LTrim(str(Worksheets("Sheet1").Range("a2")))
    base_date = DateSerial(Mid(indt, 1, 4), Mid(indt, 5, 2), Mid(indt, 7, 2))
    
    intrv = 60
    
    ReDim yymm(intrv)
    ReDim yymmf(intrv)
    ReDim yyyymm(intrv)
    ReDim yyyymmf(intrv)
    
        
    For i = 0 To intrv Step 1
        If i = 0 Then
            yymm(i) = Format(Date, "yymm")
            yyyymm(i) = Format(Date, "yyyymm")
            yymmf(i) = Format(Date, "yymm")
            yyyymmf(i) = Format(Date, "yyyymm")
        Else
        
            yymm(i) = Format(DateAdd("m", i * -1, Date), "yymm")
            yyyymm(i) = Format(DateAdd("m", i * -1, Date), "yyyymm")
            yymmf(i) = Format(DateAdd("m", i, Date), "yymm")
            yyyymmf(i) = Format(DateAdd("m", i, Date), "yyyymm")
        End If
        Debug.Print i & " " & yymm(i) & " " & yyyymm(i) & " " & yymmf(i) & " " & yyyymmf(i)
    Next i
End Sub


반응형

'VBA' 카테고리의 다른 글

VBA 다시 손대는데 생각보다 재미있구만.  (0) 2014.09.30
VBA 구조체  (0) 2014.09.29
k-means clustering in vba  (0) 2014.05.28
Access VBA  (0) 2013.04.28
MSDN - VBA SQL Union  (0) 2013.04.11

 내가 자주 가는 vba의 대마법사 타임버드님이 추천해 주신 k-means clustering in vba


 여기는 타임버드님의 이글루스.


회사에서는 이글루스가 막혀 있어서, 일단 링크만 걸어 놓는다.


 자 여기는 타임버드님이 걸어 놓으신 사이트이다.


http://www.neilson.co.za/k-means-cluster-analysis-in-microsoft-excel/


 이런 것들이 vba에서 된다고 하니, 참 당황스럽다. 사실 내가 유일하게 GUI를 만들 수 있는 것이 바로, vba이니까 짬짬히 타임버드님이 링크해 놓으신 사이트들을 들어가서 봐야겠다.

반응형

'VBA' 카테고리의 다른 글

VBA 구조체  (0) 2014.09.29
vba : date_macro  (0) 2014.09.28
Access VBA  (0) 2013.04.28
MSDN - VBA SQL Union  (0) 2013.04.11
VBA 날짜 함수 정리된 곳  (0) 2013.04.04


http://www.ehow.com/how_7379158_access-vba-query-parameters.html


http://fontstuff.com/access/index.htm


http://www.functionx.com/vbaccess/Lesson26.htm

반응형

'VBA' 카테고리의 다른 글

vba : date_macro  (0) 2014.09.28
k-means clustering in vba  (0) 2014.05.28
MSDN - VBA SQL Union  (0) 2013.04.11
VBA 날짜 함수 정리된 곳  (0) 2013.04.04
Excel VBA 이용해서 워드 파일 생성  (0) 2013.02.08

 

 

 

 

 

Sub UnionX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")
    
    ' Retrieve the names and cities of all suppliers 
    ' and customers in Brazil.
    Set rst = dbs.OpenRecordset("SELECT CompanyName," _
        & " City FROM Suppliers" _
        & " WHERE Country = 'Brazil' UNION" _
        & " SELECT CompanyName, City FROM Customers" _
        & " WHERE Country = 'Brazil';")
    
    ' Populate the Recordset.
    rst.MoveLast
    
    ' Call EnumFields to print the contents of the 
    ' Recordset. Pass the Recordset object and desired
    ' field width.
    EnumFields rst, 12

    dbs.Close

End Sub

반응형

'VBA' 카테고리의 다른 글

k-means clustering in vba  (0) 2014.05.28
Access VBA  (0) 2013.04.28
VBA 날짜 함수 정리된 곳  (0) 2013.04.04
Excel VBA 이용해서 워드 파일 생성  (0) 2013.02.08
Application.OnTime 설명  (0) 2012.12.28

http://lovendon.tistory.com/trackback/59

 

정말 예술적으로 정리된 사이트입니다.

 

반응형

'VBA' 카테고리의 다른 글

Access VBA  (0) 2013.04.28
MSDN - VBA SQL Union  (0) 2013.04.11
Excel VBA 이용해서 워드 파일 생성  (0) 2013.02.08
Application.OnTime 설명  (0) 2012.12.28
cdbl(Convert to a double)  (0) 2012.12.28

출처 : http://exceltip.com/st/Control_Word_from_Excel_using_VBA_in_Microsoft_Excel/465.html

 

Sub CreateNewWordDoc()

' to test this code, paste it into an Excel module

' add a reference to the Word-library

' create a new folder named C:\Foldername or edit the filenames in the code

Dim wrdApp As Word.Application

Dim wrdDoc As Word.Document

Dim i As Integer

  Set wrdApp = CreateObject("Word.Application")

  wrdApp.Visible = True

  Set wrdDoc = wrdApp.Documents.Add '새로운 문서 생성

  ' 또는

  'Set wrdDoc = wrdApp.Documents.Open("C:\FolderName\Filename.doc")

  ' 로컬 파일 열기

  ' word 작업 샘플

  With wrdDoc

    For i = 1

      .Content.InsertAtfer "Here is a example test line #" & i

      .Content.InsertParagraphAfter

    Next i

    If Dir("C:\FolderName\MyNewWordDoc.doc") <> "" Then

      Kill "C:\FolderName\MyNewWordDoc.doc"

    End If

    .SaveAs("C:\FolderName\MyNewWordDoc.doc")

    .Close ' 문서 close

  End With

  wrdApp.Quit ' MSWord 프로그램 종료

  Set wrdDoc = Nothing

  Set wrdApp = Nothing

End Sub

 

Sub OpenAndReadWordDoc()

' assumes that the previous procedure has been executed

Dim wrdApp As Word.Application

Dim wrdDoc As Word.Document

Dim tSting As String, tRange As Word.Range

Dim p As Long, r As Long

  Workbooks.Add ' 새로운 workbook 생성

  With Range("A1")

    .Formula = "Word Document Contents:"

    .Font.Bold = True

    .Font.Size = 14

    .Offset(1, 0).Select

  End With

  r = 3 ' MSWord 문서로부터 복사한 문자열이 시작하는 row

  Set wrdApp = CreateObject("Word.Application")

  'wrdApp.Visible = True

  Set wrdDoc = wrdApp.Documents.Open("C:\Foldername\MyNewWordDoc.doc")

  'example word operations

  With wrdDoc

    For p = 1 To .Paragraphs.Count

      Set tRange = .Range(Start:=.Paragraphs(p).Range.Start, _

           End:=.Paragraphs(p).Range.End)

      tString = tRange.Text

      tString = Left(tString, Len(tString) - 1)

      'exclude the paragraph-max

      'check if the text has the content you want

      If InStr(1, tString, "1") > 0 Then

        ' 활성화된 worksheet에 데이터 추가

        ActiveSheet.Range("A" & r).Formula = tString

        r = r + 1

      End If

    Next p

  End With

  wrdApp.Quit ' Word 프로그램 종료

  Set wrdDoc = Nothing

  Set wrdApp = Nothing

  ActiveWorkbook.Saved = True

End Sub

반응형

'VBA' 카테고리의 다른 글

MSDN - VBA SQL Union  (0) 2013.04.11
VBA 날짜 함수 정리된 곳  (0) 2013.04.04
Application.OnTime 설명  (0) 2012.12.28
cdbl(Convert to a double)  (0) 2012.12.28
벽에 부딪힌 vba  (0) 2012.08.13

+ Recent posts