Fly to the sky & Return

[엑셀 VBA] 일렬로 된 달력 만들기... 본문

프로그래밍/엑셀 & VBA

[엑셀 VBA] 일렬로 된 달력 만들기...

낼은어떻게 2016. 4. 5. 21:48
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
기본코드는 msdn에서 가저왔습니당.    

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Sub CalendarMaker()             
    MyInput = Format(Now(), "mm yyyy")                                  
    StartDay = DateValue(MyInput)                          
    Range("a1").NumberFormat = "mmmm yyyy"      
    Range("a1").Value = Application.Text(MyInput, "mmmm yyyy")     
    CurYear = Year(StartDay)       
    CurMonth = Month(StartDay)             
    FinalDay = DateSerial(CurYear, CurMonth + 11)           
    Range("A3"= "1"          
    
    For Each cell In Range("a4:a50")              
        If cell.Offset(-10).Value >= 1 Then                   
        cell.Value = cell.Offset(-10).Value + 1                                     
    
            If cell.Value > (FinalDay - StartDay) Then                       
                cell.Value = ""                                             
                Exit For                   
            End If        
        End If                  
 
    Next          
 
    For Each cell In Range("a3:a50")              
        If cell.Value = "" Then              
        Else                 
            eachday = DateSerial(CurYear, CurMonth, cell.Value)            
            dayofweek = Weekday(eachday)                 
            
            Select Case dayofweek                
                Case 1                    
                    weekname = "일"                
                Case 2                    
                    weekname = "월"               
                Case 3                    
                    weekname = "화"                    
                Case 4                    
                    weekname = "수"                
                Case 5                    
                    weekname = "목"                
                Case 6                    
                    weekname = "금"                
                Case 7                    
                    weekname = "토"                
            End Select                                                     
 
            cell.Offset(01).Value = weekname                                                
         End If          
    Next     
End Sub
cs