나눔터  
  HOME > 나눔터 > 묻고답하기 > 엑셀
엑셀
엑셀에 대한 질문과 답변을 올려주세요. 단, 취지에 맞지 않는 글은 운영자가 삭제합니다.
 "000 님, 도와주세요", "부탁 드립니다.", "급합니다!" 등과 같이 막연한 제목을 달지 말아주세요.
[필독] 빠르고 정확한 답변을 얻는 16가지 Tip !
[필독] 저작권법 개정에 따른 이용안내

작성자:  

 호우니콘 (windfos)

추천:  2
파일:     조회:  2615
제목:   병합셀 for문 Range 클래스 중 Select 메서드에 오류
     
  * 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.

 - 엑셀 버전(95,97,2000,xp,2003,2007):

* 아래줄에 질문을 작성하세요 >>

* 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.

 - 엑셀 버전(95,97,2000,xp,2003,2007):
Sub 매크로()

Dim a As Integer
Dim i As Integer
Dim j As Integer
Dim stri1 As String
Dim stri2 As String
Dim c As Integer
Dim finda As String
Dim finda1 As String
Dim finda2 As String
Dim finda3 As String
Dim finda4 As String
Dim finda5 As String

a = 1

stri1 = "▶ 운용경과"
stri2 = "▶ 투자환경 및 운용계획"
srti3 = "      상품의 특징"


  

t = Worksheets.Count

For b = 1 To t

    Sheets(b).Activate
    
    ActiveWindow.View = xlPageBreakPreview
    
Next b

    Sheets("표지").Select
    ActiveWindow.SmallScroll Down:=-39
    Range("A3:V13").Select
    Range("J3").Activate
    ActiveWindow.SmallScroll Down:=18
    Range("A3:V13,A38:V68").Select
    Range("N38").Activate
    With Selection.Font
        .Name = "HY헤드라인M"
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With

    ActiveSheet.Shapes.Range(Array("Picture 4")).Select
    Selection.ShapeRange.Top = 697
    Selection.ShapeRange.Left = 3.3

    Sheets("개요및수익률현황").Activate
    Range("G3:J3").Select
    ActiveCell.FormulaR1C1 = "적용법률"
    Range("G4").Select

rowd = Range("a1", Range("a1").End(xlDown)).rows.Count



str1 = "1. 펀드의 개요"
str2 = "2. 운용경과 및 수익률 현황"
str3 = "3. 자산현황"
str4 = "4. 투자운용전문인력 현황"
str5 = "5. 비용현황"
str6 = "6. 투자자산매매내역"
str7 = "7. 자산운용사의 고유재산 투자에 관한 사항"
str8 = " <공지사항>"
str9 = "참    고  : 펀드 용어 정리"
str10 = "* 투자자의 계좌별 수익률 정보는 판매회사의 HTS나 인터넷 뱅킹 등을 통해 조회할 수 있습니다."
str11 = "윤성주"
str12 = "변유수"

str14 = "해외지수복합"

str18 = "▶ 주요자산보유현황"
str19 = "해외수익증권"
str20 = "▶ 채권"
finda = "▶ 재산현황"
finda2 = "▶ 기간수익률"
finda3 = "▶ 보수 및 비용 지급현황"
finda5 = "▶ 총보수비용 비율"
finda4 = "종류(class)별 현황"

j = 1
i = 1


For j = 1 To t
    For i = 1 To 200

    If Sheets(j).Cells(i, 1) = str1 Then
    Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        
    ElseIf Sheets(j).Cells(i, 1) = str2 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        With Worksheets(j)
            .HPageBreaks.Add .Cells(i, 1)
        End With
        
    ElseIf Sheets(j).Cells(i, 10) = str19 Then
        Sheets("자산현황").Cells(i, 1).RowHeight = 30



    ElseIf Sheets(j).Cells(i, 1) = str3 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        
    
    ElseIf Sheets(j).Cells(i, 1) = str4 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        
    ElseIf Sheets(j).Cells(i, 1) = str5 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        With Worksheets(j)
            .HPageBreaks.Add .Cells(i, 1)
        End With
        
    ElseIf Sheets(j).Cells(i, 1) = str18 Then
        Sheets(j).Cells(i, 1).Font.Name = "굴림체"
        With Worksheets(j)
            .HPageBreaks.Add .Cells(i, 1)
        End With
        
    ElseIf Sheets(j).Cells(i, 1) = str6 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        
    ElseIf Sheets(j).Cells(i, 1) = str7 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"


    ElseIf Sheets(j).Cells(i, 1) = str8 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"

    ElseIf Sheets(j).Cells(i, 1) = str9 Then
        Sheets(j).Cells(i, 1).Font.Name = "HY헤드라인M"
        

    ElseIf Sheets(j).Cells(i, 1) = str10 Then
        Sheets(j).Cells(i, 1) = " * 투자자의 계좌별 수익률 정보는 판매회사의 HTS나 인터넷 뱅킹 등을 통해 조회할 수 있습니다."
        
    ElseIf Sheets(j).Cells(i, 1) = finda Then
    Name = Sheets(j).Cells(i + 3, 1)
    
    Sheets(j).Cells(i + 8, 11).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToLeft)).Select
    
    Selection.Replace What:=Name, Replacement:="", _
    LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
    False, ReplaceFormat:=False
    
    Range(Selection, Selection).EntireRow.AutoFit
    

    ElseIf Sheets(j).Cells(i, 1) = finda2 Then
    Name2 = Sheets(j).Cells(i + 4, 1)
    
    Sheets(j).Cells(i + 8, 7).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToLeft)).Select
    
    Selection.Replace What:=Name2, Replacement:="", _
    LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
    False, ReplaceFormat:=False
    
    Range(Selection, Selection).EntireRow.AutoFit
    


    ElseIf Sheets(j).Cells(i, 1) = finda3 Then < ----- 이 부분에서 메서드 오류가 뜹니다! '1004' 런타임 오류가 발생하였습니다: Range 클래스 중 Select 메서드에 오류가 있습니다.

    Name3 = Sheets(j).Cells(i + 3, 1)
    
    Sheets(j).Cells(i + 4, 11).Select
    Range(Selection, Selection.End(xlDown)).Select
    
    Selection.Replace What:=Name3, Replacement:="", _
    LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
    False, ReplaceFormat:=False
    
    End If

    Next i
Next j


End Sub




* 아래줄에 질문을 작성하세요 >>


    ElseIf Sheets(j).Cells(i, 1) = finda3 Then < ----- 이 부분에서 메서드 오류가 뜹니다! '1004' 런타임 오류가 발생하였습니다: Range 클래스 중 Select 메서드에 오류가 있습니다.

병합된 셀에서 드래그하여 같은 단어를 지우는 매크로를 짜고 있습니다.

오류 부분 해결하고자 질문드립니다. 감사합니다.
 
[불량 게시물 신고]  
slgi오류가 발생하게 만들어서 파일을 올려주세요02-22 (15:53)
삭제 ■신고
        
  

작성일 : 2021-02-19(17:33)
최종수정일 : 2021-02-19(17:33)