매크로 처음하시는 분들 참고하시라고 올려봅니다.
아래 주소의 첨부 파일을 참조하세요.
Sub goCalcMoney()
'관세율
tradeTaxRate = Cells(2, 2)
addTaxRate = Cells(3, 2)
moneyRate = Cells(4, 2)
Range(Cells(13, 2), Cells(21, 7)).Value = 0
k = 2
Do While k < 8
goodsMoney = Cells(8, k)
InType = Cells(6, k)
If goodsMoney < 1 Or goodsMoney = "" Then
Else
transFee = Cells(9, k)
taxFee = Cells(10, k)
weightAll = Cells(11, k)
'1차 합계
totalDallor = goodsMoney + transFee + taxFee
sumKoreaWon = totalDallor * moneyRate
Cells(13, k) = sumKoreaWon
'과세운임
i = 2
Do While i < 999
startWeight = Cells(i, 16)
If startWeight < weightAll Then
i = i + 1
Else
If sumKoreaWon > 200000 Then
transTaxFee = Cells(i - 1, 19).Value
Cells(14, k).Value = transTaxFee
Else
transTaxFee = Cells(i - 1, 18).Value
Cells(14, k).Value = transTaxFee
End If
i = 999
End If
Loop
'과세기준
standardTax = sumKoreaWon + transTaxFee
Cells(15, k) = standardTax
'관세
If standardTax < 150000 Or InType = "목록" Then
afterTax = sumKoreaWon
afterAddTax = sumKoreaWon
tradeType = "비과세"
Else
afterTax = standardTax * (1 + (tradeTaxRate / 100))
afterAddTax = afterTax * (1 + (addTaxRate) / 100)
tradeType = ""
End If
Cells(16, k) = afterTax
Cells(17, k) = afterAddTax
Cells(12, k) = tradeType
'운송비
i = 4
Do While i < 999
'몰테일 배송비
mstartWeight = Cells(i, 10)
If mstartWeight < weightAll Then
i = i + 1
Else
mTransFee = Cells(i, 11).Value
i = 999
End If
Loop
i = 4
Do While i < 999
'이하넥스 배송비
estartWeight = Cells(i, 10)
If estartWeight < weightAll Then
i = i + 1
Else
eLTransFee = Cells(i, 13).Value
eNTransFee = Cells(i, 14).Value
i = 999
End If
Loop
If mTransFee > eLTransFee Then
If eLTransFee > eNTransFee Then
lastTransFee = eNTransFee
feeSource = "이하넥스 뉴저지"
Else
lastTransFee = eLTransFee
feeSource = "이하넥스 LA"
End If
ElseIf mTransFee > eNTransFee Then
lastTransFee = eNTransFee
feeSource = "이하넥스 뉴저지"
Else
lastTransFee = mTransFee
feeSource = "몰테일"
End If
wonLastTF = lastTransFee * moneyRate
Cells(18, k) = wonLastTF
If standardTax < 150000 Or InType = "목록" Then
Cells(19, k) = afterAddTax + wonLastTF
Cells(21, k) = afterAddTax - sumKoreaWon
Else
Cells(19, k) = afterAddTax + wonLastTF - transTaxFee
Cells(21, k) = afterAddTax - sumKoreaWon
End If
Cells(20, k) = feeSource
End If
k = k + 1
Loop
End Sub
'MACRO > EXCEL-MACRO' 카테고리의 다른 글
작업 결과를 백업파일에 자동 저장하기 (0) | 2013.05.14 |
---|---|
매크로와 함수 비교 (0) | 2013.04.19 |
엑셀매크로] 리스트의 파일을 열어서 시트명과 셀값을 복사해오기 (0) | 2013.01.22 |
EXCEL MACRO-엑셀에서 파일리스트 보기 (0) | 2013.01.21 |
엑셀 매크로 -색상표 만드기 (0) | 2013.01.15 |