그래서이 파일을 사용하여 많은 입력을 넣었으며 파일 내에서 입력 한 내용이 다양합니다. 모든 입력을 완료 한 후에도 출력 탭의 카테고리가 여전히 비어 있거나 카테고리의 자막이 OPEN (의미는 해당 자막에 섹션을 할당하지 않았기 때문에 해당 행을 숨기고 여러 출력 시트여러 시트에 대해 특정 조건에 따라 Excel에서 행을 숨기려고 시도합니다.
내가 가진 현재 코드는 다음과 같습니다.
Sub Group_And_Hide()
'
' Group_And_Hide Macro
'
'
'Define Variables
Dim myRange As Range
Dim rowCount As Integer, currentRow As Integer
Dim firstZeroValueRow As Integer, lastZeroValueRow As Integer
Dim CurrentRowValue As String
Dim neighborColumnValue1 As String
Dim NGV2 As String
Dim NGV3 As String
Dim NGV4 As String
Dim NGV5 As String
Dim CheckColumn As Integer
'Select Balance Sheet
Sheets("Balance Sheet").Select
Application.ScreenUpdating = False 'Turns off screen uppdating while running
'Establish the page range
Set myRange = Range(D3, W126)
rowCount = Cells(Rows.Count, myRange.Column).End(xlUp).Row
'Reset the rows and Check
firstZeroValueRow = 0
lastZeroValueRow = 0
CheckColumn = 9
'Commands
For currentRow = 1 To rowCount
CurrentRowValue = Cells(currentRow, myRange.Column).Value
neighborColumnValue = Cells(currentRow, myRange.Column - 1).Value
If Cells(currentRow, CheckColumn).Value Like "**OPEN**" Then
'If First Cell is Open, and first blank row hasn't been assigned
If firstZeroValueRow = 0 Then
firstZeroValueRow = currentRow
End If
ElseIf Not Cells(currentRow, CheckColumn).Value Like "**OPEN**" Then
'if the cell is not Open and the row right values are 0,
'and firstBlankRow hasn't been assigned, then this is the firstBlankRow
'to consider for grouping
If (Cells(currentRow, CheckColumn + 3).Value And Cells(currentRow, CheckColumn + 4).Value And Cells(currentRow, CheckColumn + 5).Value And Cells(currentRow, CheckColumn + 6).Value = 0) Then
firstZeroValueRow = currentRow
ElseIf Cells(currentRow, CheckColumn + 3).Value And Cells(currentRow, CheckColumn + 4).Value And Cells(currentRow, CheckColumn + 5).Value And Cells(currentRow, CheckColumn + 6).Value <> 0 And firstZeroValueRow <> 0 Then
'if firstBlankRow is assigned and this row has a value with a neighbor
'who isn't 0, then the cell one row above this one is to be considered
'the lastBlankRow to include in the grouping
lastZeroValueRow = currentRow - 1
End If
End If
'if first AND last blank rows have been assigned, then create a group
'then reset the first/lastBlankRow values to 0 and begin searching for next
'grouping
If firstZeroValueRow <> 0 And lastZeroValueRow <> 0 Then
Range(Cells(firstZeroValueRow, myRange.Column), Cells(lastZeroValueRow, myRange.Column)).EntireRow.Select
Selection.Group
firstZeroValueRow = 0
lastZeroValueRow = 0
End If
Next
ActiveSheet.Outline.ShowLevels RowLevels:=1 'Minimize all the groups
Application.ScreenUpdating = True 'Turns on screen updating when done
End Sub
그래서 기본적으로 나는 다음 시트를 선택하여 그 코드를 반복 희망 말 "손익 계산서"
내가 결과에 대한 희망 코드는 다음과 같은 파일을 가져옵니다.
,451,515,Assets:
Current Assets 4000 50000 60000
Fixed Assets 100 8000 500
Liabilities:
C. Liab. - - -
LT Liab. - - -
Equity:
Capital Stock 4100 58000 60500
**OPEN** - - -
Net Income (300) (100) (500)
RE 300 100 500
그리고이처럼 보이는 끝낼 것 :
Assets:
Current Assets 4000 50000 60000
Fixed Assets 100 8000 500
Liabilities:
Equity:
Capital Stock 4100 58000 60500
Net Income (300) (100) (500)
RE 300 100 500
그래서 나는 0 값 (대시)하지 공백을 숨기고해야합니다.
이 코드에 대한 도움을 주셔서 감사합니다.
모든 시트에 대해 위의 스크립트를 반복해서 찾으십니까? 또는 행을 숨기는 데 도움이 필요합니까? 또한 행을 그룹화하는 것으로 나타났습니다 ... 그룹 내에 '숨겨진'행이있는 경우 축소/확장 할 때 '숨김'상태가됩니다. – CRUTER
혼란을 드려 죄송합니다. 분명히 말하면 실제로 "숨김"행을 원하지 않지만보기를 숨기도록 그룹화하고 접을 때 여러 페이지에 대해이 스크립트를 반복 할 수 있기를 원합니다. 감사! – BotBadger112233