시트 열기시 내 2010 매크로가 업데이트됩니다. 2016은 대상 시트를 새로운 '인스턴스'에서 열었을 때도 똑같이 작동합니까? 그것은 멍청한 증거가되어야합니다 (나는 왜 그들이 P : 그렇게 할 것을 요구했는지 모르겠습니다). 따라서 매크로는 시트를 열 때 한번 실행해야합니다. 원본 시트에 119 이상의 값이 삽입 될 때마다 시트가 두 번째 모니터에서 열리는 경우; 잠재적으로 매우 큰 시트와 meh 노트북 때문에 불필요하게 실행하지 마십시오.VBA 입력 및 공백 행없이 다른 시트에 복사
나는이 매크로를 사용하여 대학에서 사용하는 시트에 Word로 내보내기 전에 빈 행을 지우는 '복잡한'수식이나 매크로가 필요하지 않습니다. 나는 2010 년에 그것을 만들었지 만, 다음 주에 2016 년에 그것을 시험 할 수는 없습니다.
대상 시트 (J03)에있는 매크로;
Private Sub worksheet_activate()
원본 시트 (WTB);
Private Sub Run_When_Value_Greather_Than_119_Is_Entered_In_Column_G()
Google은 공백 행, 복사, 빈 행, 다른 활성화 방법 및 비어 있지 않은 행에 대한 실행 결과로 인해 막혔습니다. 아마 뭘 찾을 지 모르겠다.
전체 코드;
Private Sub worksheet_activate()
Dim Max As Long, MaxD As Long 'Determine the amount of filled rows
Dim wsWtB As Worksheet, wsJ03 As Worksheet
Dim wb As Workbook
Dim i As Integer, j As Integer 'i and j for the row numbers
Application.ScreenUpdating = False 'screenupdating of for max speeds
Set wb = ThisWorkbook
Set wsJ03 = Sheets("J_03")
Set wsWtB = Sheets("WTB")
Max = WorksheetFunction.Max(wsWtB.Range("A3:A1600")) 'Amount of rows with data
Max = Max + 3 'Ignore the headers
MaxD = WorksheetFunction.Max(wsJ03.Range("A3:A1600"))
MaxD = MaxD + 2
j = 9 'The rownumber where the copying needs to start
wsJ03.Range("B9", Cells(MaxD, 5)).ClearContents 'Clear the old values
For i = 3 To Max 'The copying loop has to start after the headers at row 3
If wsWtB.Cells(i, 7).Value > 119 Then 'Do stuff if...
wsJ03.Cells(j, "B").Value = Chr(39) & wsWtB.Cells(i, "B").Value 'At a '
wsJ03.Cells(j, "C").Value = Chr(39) & wsWtB.Cells(i, "C").Value 'at the start
wsJ03.Cells(j, "D").Value = Chr(39) & wsWtB.Cells(i, "D").Value 'so a zero is
wsJ03.Cells(j, "E").Value = Chr(39) & wsWtB.Cells(i, "E").Value 'displayed
j = j + 1 'Set the next row for the target sheet
Else
End If
Next i
Application.ScreenUpdating = True
End Sub
딸꾹질없이 작업 한 첫 번째 코드입니다 :-) 의견을 말하고 프로퍼티 태그를 사용하십시오.
코엔.
편집; (마지막 셀을 찾는 다른 방법)
?thisworkbook.sheets("WTB").cells(rows.Count,"A").end(xlup).row
1047 '<- Rownumber of the last cell with a Formula to create/force
successive
numbers
?thisworkbook.sheets("WTB").columns("A").Find(What:="*", LookIn:=xlValues,
SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
5 '<- Rownumber of the last cell with a value. Includes the header
rows
?WorksheetFunction.Max(thisworkbook.sheets("WTB").Range("A3:A1600"))
3 '<- Highest number in A3:A1600 and also the amount units/rows that
need to be copied to "J_03"
시트에 '물건'의 양을 준 기능이 필요했습니다. 이 경우 3이지만 1600까지 올라갈 수 있습니다.
편집 2; (Google 시트를 통해 내가 무엇을하고 있는지 확인할 수 있습니다.) https://docs.google.com/spreadsheets/d/1I5qLeOS0DWcwncs_ium_J0Vp6b4nzTsiE0ndbKtpsC0/edit?usp=sharing
편집 3; 명확한 범위 부분에 오류가있었습니다. wsJ03.Range ("B9", 세포 (MaxD, 5)) .ClearContents '지우기 이전 값
잘 작동하는 것처럼 보입니다 ... 특정 문제를 발견하면 알려주세요 ... Max를 계산하는 방식을 Max = wsWtB.Cells (Rows.Count, "A"). End (xlUp) .Row – Xabier
안녕하세요, 끝 (xlup)도 수식이있는 셀을 찾습니다. range.find ("*"및 xlvalues 찾기)를 사용하기로 선택했으나 사용자가이 시트에서 연속 번호를 사용해야합니다 (COUNTA() 및 MAX (A)가 많이 있음을 확인합니다. 누군가가 두통을주는 G 열에 120 이상을 입력 할 때마다 실행 EDIT : 실제로 마지막 행에 무작위 수식이 있음 : P –
늦게 편집하려면 마지막 행을 찾기 위해 다른 옵션을 추가했으며 그 이유는 무엇입니까? 누군가가 우연히 발견되어 유용하다고 느낄 수도 있습니다. 확장 된 사무실에있는 "ws_change() & Intersect (Target, Range())"와 같이 시도 할 것입니다; https : // www. extendoffice.com/documents/excel/4423-excel-run-macro-on-cell-change.html. 내가 생각하기에 복잡하다고 생각 했었지. –