엑셀에서 방위 계산하는 VBA코드

데이터 샘플이 이런 형태

A            B        c

WindSpeed1 WindDir1
6.0 276.9
5.8 346.1
8.1 276.3
7.1 253.4
4.9 256.1
6.8 275.4

Sub ChangeDir()
    Dim num As Double
    num = ActiveCell.Offset(0, -1).Value
    ' ActiveCell.Offset(0,-1).Value
    Debug.Print (num)

    ' If IsEmpty(num) Or num = 0 Then
    If ActiveCell.Offset(0, -2).Value < 0.4 Then
        ActiveCell.Value = "Calm"
    ElseIf IsEmpty(ActiveCell.Offset(0, -1).Value) Then
        ActiveCell.Value = ""
    ElseIf Scope(11.25, 33.75, num) Then
        ActiveCell.Value = "NNE"
    ElseIf Scope(33.75, 56.25, num) Then
        ActiveCell.Value = "NE"
    ElseIf Scope(56.25, 78.75, num) Then
        ActiveCell.Value = "ENE"
    ElseIf Scope(78.75, 101.25, num) Then
        ActiveCell.Value = "E"
    ElseIf Scope(101.25, 123.75, num) Then
        ActiveCell.Value = "ESE"
    ElseIf Scope(123.75, 146.25, num) Then
        ActiveCell.Value = "SE"
    ElseIf Scope(146.25, 168.75, num) Then
        ActiveCell.Value = "SSE"
    ElseIf Scope(168.75, 191.25, num) Then
        ActiveCell.Value = "S"
    ElseIf Scope(191.25, 213.75, num) Then
        ActiveCell.Value = "SSW"
    ElseIf Scope(213.75, 236.25, num) Then
        ActiveCell.Value = "SW"
    ElseIf Scope(236.25, 258.75, num) Then
        ActiveCell.Value = "WSW"
    ElseIf Scope(258.75, 281.25, num) Then
        ActiveCell.Value = "W"
    ElseIf Scope(281.25, 303.75, num) Then
        ActiveCell.Value = "WNW"
    ElseIf Scope(303.75, 326.25, num) Then
        ActiveCell.Value = "NW"
    ElseIf Scope(326.25, 348.75, num) Then
        ActiveCell.Value = "NNW"
    Else
        ActiveCell.Value = "N"
    End If

    num = ActiveCell.Offset(1, 0).Select

End Sub

Function Scope(small As Double, big As Double, num As Double)

    If small <= num And num < big Then
        Scope = True
    Else
        Scope = False
    End If

End Function

윈도우7 64이상에서 엑셀 화면 여러개 띄우기

레지스트리 편집을 해야한다.

 

복구방법 : http://answers.microsoft.com/ko-kr/office/forum/office_2010-excel/%EC%97%91%EC%85%80-2010-%EC%83%88/b0569b63-4e96-400f-b992-2f4bec22b0e9?auth=1

 

필요에 다라 변경한다.

8은 xls, 12는 xlsx CSV는 csv파일… 하나하나 해줘야한다.

HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command
여기서 [기본값]을 수정
“C:\Program Files\Microsoft Office\Office14\EXCEL.EXE” /dde
이렇게 돼 있는걸 다음처럼 수정
“C:\Program Files\Microsoft Office\Office14\EXCEL.EXE” /en “%1”
[command]를 그냥 삭제

HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command
여기서

그리고 Open밑에 있는 ddeexec디렉토리 삭제 (경고메세지가 뜨지만 과감히 삭제해주고 엑셀창을 실행시키면 두개가 뜬다)

HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open

HKEY_CLASSES_ROOT\Excel.CSV\shell\Open