<사용자 정의 함수>

(1) alt+f11 -> [삽입]-[모듈]

(2) if

Public function

fn단가(구분)

if 구분 = “성인” then

    fn단가=5000

elseif

else

end if *주의 끝내줘야함

(3) select case

Public function

fn단가(구분)

select case 변수값

    case =”A”

        fn단가=50000

    case else

        fn단가<=0

end select

* 값이 숫자일 때 50이상 – case is >=50

30이상 50이하 – case 30 to 50

 

1)

Public Function fn비고(친환경인증, 제조년도, 판매량)

If 친환경인증 = "무농약" And 제조년도 = 2010 Then

    If 판매량 >= 40 Then

        fn비고 = "추천상품"

    Else

        fn비고 = ""

    End If

End If

End Function

* 0표시 숨기기 : 셀서식 사용자지정 0;-0;;@

2)

Public Function fn비고(청구방법)

Select Case 청구방법

Case "E-mail"

    fn비고 = "5%할인"

Case "핸드폰"

    fn비고 = "3%할인"

Case Else

    fn비고 = ""

End Select

End Function

 



+ Recent posts