1
Excel 시트의 10 번째 항목마다 굵은 글꼴을 사용하는 루프가 있습니다. 그러나 20 번째 항목마다 굵은 글꼴을 사용하고 싶습니다. 이 문제를 어떻게 해결할 수 있습니까? 어떤 도움이라도 대단히 감사합니다. 여기 VBA : 매 20 번째 셀을 굵게 표시
내가 함께 일하고 있어요 코드입니다 :'insert xxxx9 after xxxx8 if needed
For i = 3 To counter - 1
If Cells(i, 1).Value Mod 10 = 8 Then
' counter = counter + 1
If Cells(i + 1, 1) <> Cells(i, 1) + 1 Then
i = i + 1
Rows(i & ":" & i).Select
Selection.Insert Shift:=xlDown
Cells(i, 1) = Cells(i - 1, 1) + 1
Range("A" & 20).Select
Selection.Font.Bold = True
Cells(i, 2) = "900"
Range("B" & i).Select
Selection.Font.Bold = True
Cells(i, 3) = "chk"
Range("C" & i).Select
Selection.Font.Bold = True
Cells(i, 6) = "1"
Range("F" & i).Select
Selection.Font.Bold = True
Else
i = i + 1
Rows(i & ":" & i).Select
Range("A" & i).Select
Selection.Font.Bold = True
End If
End If
Next
'count number of entries
counter = 2
While (Cells(counter, 1).Value <> "" Or Cells(counter, 1).Value <> Null)
counter = counter + 1
Wend
'insert xxxx9 after xxxx8 if needed
For i = 3 To counter - 1
If Cells(i, 1).Value Mod 10 = 8 Then
' counter = counter + 1
If Cells(i + 1, 1) <> Cells(i, 1) + 1 Then
i = i + 1
Rows(i & ":" & i).Select
Selection.Insert Shift:=xlDown
Cells(i, 1) = Cells(i - 1, 1) + 1
Range("A" & 20).Select
Selection.Font.Bold = True
Cells(i, 2) = "900"
Range("B" & i).Select
Selection.Font.Bold = True
Cells(i, 3) = "chk"
Range("C" & i).Select
Selection.Font.Bold = True
Cells(i, 6) = "1"
Range("F" & i).Select
Selection.Font.Bold = True
Else
i = i + 1
Rows(i & ":" & i).Select
Range("A" & i).Select
Selection.Font.Bold = True
End If
End If
Next
'for ... next'가 'for i = 3 To counter - 1 step 20'과 같이 반복되는 방식을 변경하십시오. 이렇게하면 올바른 행에 있는지 확인해야 할 필요성을 제거하여 루틴을 빠르게 처리 할 수 있습니다. – Jeeped
도움에 감사드립니다. 그것은 일하는 방식으로 진행되었지만 이제는 20 번째 항목에도 대담한 자세를 취하는 것을 중단했습니다. –
잘 모르겠지만 처리를 위해 매 10 번째 행을 선택하는 것처럼 보입니다. 즉, 첫 번째 열에 연속 된 숫자가 포함될 것으로 예상되는 것처럼 보입니다. 그러면 셀 (i, 1) .Value Mod 10 = 8 '은 8, 18, 28 등의 값을 가진 행을 선택합니다. 이렇게하면 @Jeeped 제안이 왜 붕괴를 멈추게했는지 설명 할 수 있습니다. 좋은 도움을 얻기 위해 당신의 목적을 더 잘 설명해야한다고 생각합니다. – vknowles