1. VBA (Visual Basic for Application)
Microsoftμμ κ°λ°ν νλ‘κ·Έλλ° μΈμ΄μ λλ€.
1-1 VBAμ κΈ°λ₯
μ£Όλ‘ Microsoft Office μ ν리μΌμ΄μ (Excel, Word, Access λ±)μ μλν μμ μ μν΄ μ¬μ©λ©λλ€.
VBAλ Visual Basic μΈμ΄λ₯Ό κΈ°λ°μΌλ‘ νλ©°, μ¬μ©μκ° λ§€ν¬λ‘λ₯Ό μμ±νκ±°λ
볡μ‘ν λ°λ³΅ μμ μ μλνν μ μκ² ν΄μ€λλ€.
2. VBS (Visual Basic Script)
VBS(Visual Basic Script)λ Microsoftμμ κ°λ°ν μ€ν¬λ¦½νΈ μΈμ΄μ λλ€.
2-1 VBSμ κΈ°λ₯
μ£Όλ‘ Windows νκ²½μμμ μλν μμ μ μννλ λ° μ¬μ©λ©λλ€.
VBScriptλ VB (Visual Basic) μΈμ΄λ₯Ό κΈ°λ°μΌλ‘ νλ©°,
κ°λ¨ν μ€ν¬λ¦½νΈ μμ±μΌλ‘ νμΌ μ‘°μ, μμ€ν κ΄λ¦¬, μΉ λΈλΌμ°μ μ μ΄ λ±μ ν μ μμ΅λλ€.
3. ChatGPTλ₯Ό νμ©ν VBA ,VBS μμ±νλ λ°©λ²
3-1 μ±μ μ²λ¦¬ (VBA)
• μ 무 μ€λͺ
score.xlsx νμΌλ΄μ μ±μ λ°μ΄ν°λ₯Ό νμ©ν΄ κ°μΈλ³ μ΄μ , κ³Όλͺ©λ³ μ΄μ , μμ°¨λ₯Ό μΆλ ₯ν΄λ³΄μ
• ν둬ν¬νΈ
νμλ€μ κ΅μ΄, μμ΄, μν μ μλ₯Ό νμ©νμ¬ κ°μΈμ΄μ , κ³Όλͺ©μ΄μ , μμ°¨λ₯Ό μΆλ ₯ν΄ μ£Όλ VBA μ½λλ₯Ό μμ±ν΄μ€.
λ¨, 8νμ μ°μ°μμ μ μΈνκ³ κ³Όλͺ©μ΄μ μ B8μ μμ D8μ μ μΆλ ₯ν΄ μ€
• κ²°κ³Ό (VBA μ½λ)
Sub CalculateScores()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long, j As Long
Dim scores() As Long
Dim tempScore As Long
' νμ¬ μν¬μνΈλ₯Ό λ³μλ‘ μ€μ
Set ws = ThisWorkbook.Sheets(1)
' λ§μ§λ§ νμ μ°Ύμ (κ°μ₯ μλ λ°μ΄ν°κ° μλ ν)
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' κ° νμμ κ°μΈ μ΄μ μ κ³μ°νμ¬ Eμ΄μ μ
λ ₯
For i = 2 To lastRow
If i <> 8 Then ' 8νμ μ μΈ
ws.Cells(i, 5).Value = ws.Cells(i, 2).Value + ws.Cells(i, 3).Value + ws.Cells(i, 4).Value
End If
Next i
' κ΅μ΄, μμ΄, μνμ κ³Όλͺ© μ΄μ μ B8, C8, D8 μ
μ μ
λ ₯
ws.Cells(8, 2).Value = Application.WorksheetFunction.Sum(ws.Range("B2:B" & lastRow)) - ws.Cells(8, 2).Value
ws.Cells(8, 3).Value = Application.WorksheetFunction.Sum(ws.Range("C2:C" & lastRow)) - ws.Cells(8, 3).Value
ws.Cells(8, 4).Value = Application.WorksheetFunction.Sum(ws.Range("D2:D" & lastRow)) - ws.Cells(8, 4).Value
' μμ°¨λ₯Ό κ³μ°νμ¬ Fμ΄μ μ
λ ₯
ReDim scores(2 To lastRow)
For i = 2 To lastRow
If i <> 8 Then
scores(i) = ws.Cells(i, 5).Value
End If
Next i
For i = 2 To lastRow
If i <> 8 Then
tempScore = scores(i)
ws.Cells(i, 6).Value = 1
For j = 2 To lastRow
If j <> 8 And tempScore < scores(j) Then
ws.Cells(i, 6).Value = ws.Cells(i, 6).Value + 1
End If
Next j
End If
Next i
MsgBox "μ μ κ³μ° λ° μμ°¨ μ°μΆμ΄ μλ£λμμ΅λλ€."
End Sub
• μ½λλ₯Ό νμ©ν μμ ν
3-2 μ±μ μ²λ¦¬ (VBS)
• μ 무 μ€λͺ
score.xlsx νμΌλ΄μ μ±μ λ°μ΄ν°λ₯Ό νμ©ν΄ κ°μΈλ³ μ΄μ , κ³Όλͺ©λ³ μ΄μ , μμ°¨λ₯Ό μΆλ ₯ν΄λ³΄μ
• ν둬ν¬νΈ
νμλ€μ κ΅μ΄, μμ΄, μν μ μλ₯Ό νμ©νμ¬ κ°μΈμ΄μ , κ³Όλͺ©μ΄μ , μμ°¨λ₯Ό μΆλ ₯ν΄ μ£Όλ VBScriptλ₯Ό μμ±ν΄μ€.
λ¨, 8νμ μ°μ°μμ μ μΈνκ³ κ³Όλͺ©μ΄μ μ B8μ μμ D8μ μ μΆλ ₯ν΄ μ€
• κ²°κ³Ό (VBS μ½λ)
' Excel μ ν리μΌμ΄μ
κ°μ²΄ μμ±
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
' Excel μν¬λΆ μ΄κΈ° (κ²½λ‘λ₯Ό μμ νμ¬ μ¬μ©νμΈμ)
Set objWorkbook = objExcel.Workbooks.Open("C:\κ²½λ‘\νμΌλͺ
.xlsx")
' 첫 λ²μ§Έ μνΈ μ ν
Set objSheet = objWorkbook.Sheets(1)
' λ§μ§λ§ ν κ³μ°
lastRow = objSheet.Cells(objSheet.Rows.Count, "A").End(-4162).Row ' -4162λ xlUp μμ
' κ°μΈ μ΄μ κ³μ° (8ν μ μΈ)
For i = 2 To lastRow
If i <> 8 Then
totalScore = objSheet.Cells(i, 2).Value + objSheet.Cells(i, 3).Value + objSheet.Cells(i, 4).Value
objSheet.Cells(i, 5).Value = totalScore
End If
Next
' κ³Όλͺ© μ΄μ κ³μ° (8ν μ μΈ)
korTotal = 0
engTotal = 0
mathTotal = 0
For i = 2 To lastRow
If i <> 8 Then
korTotal = korTotal + objSheet.Cells(i, 2).Value
engTotal = engTotal + objSheet.Cells(i, 3).Value
mathTotal = mathTotal + objSheet.Cells(i, 4).Value
End If
Next
objSheet.Cells(8, 2).Value = korTotal
objSheet.Cells(8, 3).Value = engTotal
objSheet.Cells(8, 4).Value = mathTotal
' μμ°¨ κ³μ° (8ν μ μΈ)
Dim scores()
ReDim scores(2 To lastRow)
For i = 2 To lastRow
If i <> 8 Then
scores(i) = objSheet.Cells(i, 5).Value
End If
Next
For i = 2 To lastRow
If i <> 8 Then
rank = 1
For j = 2 To lastRow
If j <> 8 And scores(i) < scores(j) Then
rank = rank + 1
End If
Next
objSheet.Cells(i, 6).Value = rank
End If
Next
' λ©μμ§ μΆλ ₯
MsgBox "μ μ κ³μ° λ° μμ°¨ μ°μΆμ΄ μλ£λμμ΅λλ€."
' Excel μν¬λΆ μ μ₯ ν λ«κΈ°
objWorkbook.Save
objWorkbook.Close False
' Excel μ ν리μΌμ΄μ
μ’
λ£
objExcel.Quit
' κ°μ²΄ ν΄μ
Set objSheet = Nothing
Set objWorkbook = Nothing
Set objExcel = Nothing
• VBSλ₯Ό νμ©ν μμ ν
λ΄μ£Όμ λΆλ€ λͺ¨λ κ°μ¬ν©λλ€.
'πͺπππππππ πΊππππππ π¬ > AI κΈ°λ° ChatGPT νμ©' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[ChatGPT νμ©] ChatGPTλ₯Ό νμ©ν PowerPoint & Word μ¬μ©λ² (0) | 2024.08.31 |
---|---|
[ChatGPT νμ©] ChatGPTλ₯Ό νμ©ν GAS μ¬μ©λ² (0) | 2024.08.29 |
[ChatGPT νμ©] ChatGPTλ₯Ό νμ©ν Excel ν¨μ μ¬μ©λ² (0) | 2024.08.25 |
[ChatGPT νμ©] ChatGPTλ₯Ό νμ©ν Excel μ¬μ©λ² (0) | 2024.08.16 |
[ChatGPT νμ©] ChatGPTλ₯Ό νμ©ν μλΉμ€ & λ°μ΄ν°νλ μ μμ± (0) | 2024.08.13 |