๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Tools/Excel

[Excel] VBA ์ •๋ฆฌ

๋ฐ˜์‘ํ˜•

 

 

https://mainia.tistory.com/5533

 

์—‘์…€ VBA ์‹œํŠธ ๋”๋ธ”ํด๋ฆญ ์ด๋ฒคํŠธ๋กœ ์…€์— ๋ฐฐ๊ฒฝ์ƒ‰ ๋ณ€๊ฒฝํ•˜๊ธฐ

VBA ์—์„œ๋Š” ์‹œํŠธ์™€ ๊ด€๋ จ๋œ ์ด๋ฒคํŠธ๊ฐ€ ์ด๋ฏธ ์ค€๋น„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ๋ช‡ ๋ฒˆ์˜ ํด๋ฆญ์œผ๋กœ ์‹œํŠธ์—์„œ ์ผ์–ด๋‚˜๋Š” ์ด๋ฒคํŠธ๋ฅผ ๊ฐ€๋กœ์ฑ„์„œ ์ž์‹ ์ด ์›ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ ์ค‘ ํ•˜๋‚˜๊ฐ€ ์…€์„ ๋งˆ

mainia.tistory.com

 

 

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    If Target.Interior.Color = vbRed Then
        Target.Interior.Color = xlNone
    Else
        Target.Interior.Color = vbRed
    End If
    Cancel = True
    
End Sub

 

 

https://blog.daum.net/monogatari/13409674

 

[์—‘์…€] ์…€์„ ํƒ์‹œ ๊ฐ’์ด ๋‹ค๋ฅธ์…€์— ์ž๋™ํ‘œ์‹œ VBA

์…€ ํด๋ฆญ์‹œ ๊ฐ’์ด B2์— ์ž๋™์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋„๋ก ํ•ด๋ณด์ž ๋ฉ”๋‰ด ๋„๊ตฌ-๋งคํฌ๋กœ-visual basic editor ์˜ค๋ฅธ์ชฝ VBAProject์—์„œ ์‹œํŠธ์„ ํƒ ์™ผ์ชฝ์— ํฐ๋ฐ”ํƒ• ์ฝ”๋“œ์ž…๋ ฅ๋ž€์ด ๋‚˜์˜ค๋ฉด ์•„๋ž˜๋ฅผ ๋ณต์‚ฌํ•ด์„œ ๋ถ™์—ฌ๋„ฃ๋Š”๋‹ค ------------------

blog.daum.net

 

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("b4:b200")) Is Nothing Then
        Range("b2").Value = TargetValue
    End If
End Sub

 

 

 

 

https://pfe2000.tistory.com/382

 

์—‘์…€ ์…€ ํด๋ฆญ ๋งคํฌ๋กœ ์—ฐ๊ฒฐํ•˜๊ธฐ (VBA ๋ฌธ๋ฒ• ๋ชฐ๋ผ๋„ ๋˜์š”^^)

ํŠน์ • ์…€์„ ํด๋ฆญํ•˜๋ฉด ๋งคํฌ๋กœ๊ฐ€ ๋™์ž‘ํ•˜๋Š” ์˜ˆ์ œ๋ฅผ ๊ฐ™์ด ํ•ด ๋ด…์‹œ๋‹ค. 1. ์šฐ์„  Alt + F11 ์„ ๋ˆŒ๋Ÿฌ์„œ VBA ํŽธ์ง‘์ฐฝ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. 2. ๋งคํฌ๋กœ ์ ์šฉํ•  Sheet๋ฅผ ์„ ํƒํ•˜์—ฌ ๋”๋ธ” ํด๋ฆญํ•˜์—ฌ ๋‚˜์˜จ ์ฐฝ์— ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ Copy &

pfe2000.tistory.com

 

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Selection.Count = 1 Then
        If Not Intersect(Target, Range("e1")) Is Nothing Then
            Call ์›ํ™”ํ‘œ์‹œ
        End If
        If Not Intersect(Target, Range("d2")) Is Nothing Then
            Call ์˜ค๋ฆ„์ •๋ ฌ
        End If
        If Not Intersect(Target, Range("d1")) Is Nothing Then
            Call ๋‚ด๋ฆผ์ •๋ ฌ
        End If
        If Not Intersect(Target, Range("c1")) Is Nothing Then
            Call ์ˆ˜์ž…๋ณด๊ธฐ
        End If
        If Not Intersect(Target, Range("b1")) Is Nothing Then
            Call ์ „์ฒด๋ณด๊ธฐ
        End If
        If Not Intersect(Target, Range("b4")) Is Nothing Then
            Call ์ง€์ถœ_์ €์ถ•_ํˆฌ์ž
        End If
        If Not Intersect(Target, Range("b5")) Is Nothing Then
            Call ์ง€์ถœ_์ฃผ๊ฑฐ
        End If
        If Not Intersect(Target, Range("b6")) Is Nothing Then
            Call ์ง€์ถœ_์‹๋น„
        End If
        If Not Intersect(Target, Range("b7")) Is Nothing Then
            Call ์ง€์ถœ_์ƒํ™œ์šฉํ’ˆ
        End If
        If Not Intersect(Target, Range("b8")) Is Nothing Then
            Call ์ง€์ถœ_์˜๋ณต_๋ฏธ์šฉ
        End If
        If Not Intersect(Target, Range("b9")) Is Nothing Then
            Call ์ง€์ถœ_๊ฑด๊ฐ•
        End If
        If Not Intersect(Target, Range("b10")) Is Nothing Then
            Call ์ง€์ถœ_์ž๊ธฐ๊ณ„๋ฐœ
        End If
        If Not Intersect(Target, Range("b11")) Is Nothing Then
            Call ์ง€์ถœ_์ž๋™์ฐจ
        End If
        If Not Intersect(Target, Range("b12")) Is Nothing Then
            Call ์ง€์ถœ_์œก์•„
        End If
        If Not Intersect(Target, Range("b13")) Is Nothing Then
            Call ์ง€์ถœ_๋ณดํ—˜
        End If
        If Not Intersect(Target, Range("b14")) Is Nothing Then
            Call ์ง€์ถœ_์ด๋ฒคํŠธ
        End If
        If Not Intersect(Target, Range("b15")) Is Nothing Then
            Call ์ง€์ถœ_์„ฌ๊น€๋น„
        End If
        If Not Intersect(Target, Range("b16")) Is Nothing Then
            Call ์ง€์ถœ_ํ—Œ๊ธˆ
        End If
        If Not Intersect(Target, Range("b17")) Is Nothing Then
            Call ์ง€์ถœ_๊ธฐ๋ถ€
        End If
        If Not Intersect(Target, Range("b18")) Is Nothing Then
            Call ์ง€์ถœ_ํ†ต์‹ ๋น„
        End If
        If Not Intersect(Target, Range("b19")) Is Nothing Then
            Call ์ง€์ถœ_๊ธฐํƒ€
        End If
    End If
End Sub

 

 

 

 

 Dim ~ As Boolean : a์™€ b๊ฐ€ Boolean ํ˜•

Sub T()

    Dim a As Boolean
    Dim b As Boolean

    a = True
    b = 0
    Debug.Print (a)
    Debug.print (b)

End Sub

 

 

https://wikidocs.net/33048

 

03-1 ๋‹ค์‹œ ๋ณ€์ˆ˜

์ˆ˜ํ•™์—์„œ ๋ณ€์ˆ˜๋Š” ์ˆซ์ž์˜€์Šต๋‹ˆ๋‹ค. '์ˆ˜'ํ•™์ด๊ณ  ๋ณ€'์ˆ˜' ๋‹ˆ๊นŒ์š”! ์ฝ”๋”ฉ์ด ์ˆ˜ํ•™๊ณผ ๋‹ค๋ฅธ ์ ์ด ์—ฌ๊ธฐ์„œ ๋˜ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์—์„œ ๋ณ€์ˆ˜๋Š” ์ˆซ์ž๋งŒ ๋‹ด๋Š” ๊ฒŒ ์•„๋‹ˆ๋ผ '**๋ฐ์ดํ„ฐ**' ...

wikidocs.net

 

 

 

 

 

Function. ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ

Sub T()

    Cells(1, 1) = ๋ฉ˜ํŠธ(์ด๋ฆ„)

End Sub

Function ๋ฉ˜ํŠธ(์ด๋ฆ„)

    ment = "์•ˆ๋…•ํ•˜์„ธ์š”"
    ment = ment + ์ด๋ฆ„
    ment = ment + "๋‹˜ ํ”„๋กœ๊ทธ๋žจ์„ ์‹œ์ž‘ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค."

    ๋ฉ˜ํŠธ = ment

End Function

 

 

 

 

 

 

 

 

 

https://wikidocs.net/46453

 

04-2 ์ง์ ‘ ๋งŒ๋“œ๋Š” ํ•จ์ˆ˜

์ด๋ฒˆ์— ๋ฐฐ์šธ ๊ฑด **Functionํ”„๋กœ์‹œ์ ธ** ์ž…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋ง๋กœ ํ•จ์ˆ˜ ์ฃ . Sub ํ”„๋กœ์‹œ์ ธ์™€ ๋ชจ๋‘ ๋˜‘๊ฐ™๊ณ , ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ”๊นฅ์—์„œ ๊ฐ’์„ ๋ฐ›์•„์˜ค๋Š” ๊ฒƒ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ,๋ผ, ...

wikidocs.net

 

 

 

 

 

 

์ฐธ๊ณ 

https://wikidocs.net/33048

 

03-1 ๋‹ค์‹œ ๋ณ€์ˆ˜

์ˆ˜ํ•™์—์„œ ๋ณ€์ˆ˜๋Š” ์ˆซ์ž์˜€์Šต๋‹ˆ๋‹ค. '์ˆ˜'ํ•™์ด๊ณ  ๋ณ€'์ˆ˜' ๋‹ˆ๊นŒ์š”! ์ฝ”๋”ฉ์ด ์ˆ˜ํ•™๊ณผ ๋‹ค๋ฅธ ์ ์ด ์—ฌ๊ธฐ์„œ ๋˜ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ์ฝ”๋”ฉ์—์„œ ๋ณ€์ˆ˜๋Š” ์ˆซ์ž๋งŒ ๋‹ด๋Š” ๊ฒŒ ์•„๋‹ˆ๋ผ '**๋ฐ์ดํ„ฐ**' ...

wikidocs.net

 

 

 

 

๋ฐ˜์‘ํ˜•

'Tools > Excel' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Excel] VBA ๋งคํฌ๋กœ ํฌ๋กค๋ง ๋งŒ๋“ค๊ธฐ  (0) 2022.07.23