누군가 나를 도와 줄 수 있기를 바랍니다. 그래서 다음과 같은 코드가 있습니다. 독립 코드는 스스로 잘 작동하지만 스크립트를 실행할 때 첫 번째 조건 만 반복합니다. 내가 원하는 것은 매번 모든 코드를 반복하는 것입니다. 나는 이것이 내가 누락 된 작은 것 같지만 해결책을 찾지 못하는 것 같다.sub는 두 번째 if 문을 반복하지 않습니다. vba
Sub Copypre()
Dim i As Integer
Dim n As Integer
For i = 2 To 10
'Checks the number of entries in the "Pre" table, to make sure that there are no spaces between the lines
On Error Resume Next
n = Worksheets("Pre").Range("A2:A6000").Cells.SpecialCells(xlCellTypeConstants).Count
If n = Null Then
n = i
'Goes through the different sheets to find all "pre" values and paste them in the "Pre" sheet
If ThisWorkbook.Sheets("273").Range("A" & i).Value = "Pre" Then
Range(Cells(i, 1), Cells(i, 3)).Select
Selection.Copy
Sheets("Pre").Select
Range("A" & n).Select
ActiveSheet.Paste
Sheets("2736").Select
End If
End If
Next i
End Sub
소스 워크 시트의 이름이 * 273 *인지 * 2736 *인지는 분명하지 않습니다. – Jeeped
문제가 무엇인지 알아내는 것은 어렵지만'If n = null'이라는 잘못된 코드가있을 것입니다. 'n'은 정수로 정의되며 null 일 수 없습니다. 테스트를'If n = 0'으로 변경해야합니다. 어쩌면이 문제가 해결 될 것입니다. – DeanOC
한 시트에서 다음 시트로 이동하는 방법 (원하는 경우) – pnuts