Advertisement
Guest User

NetsuiteToExcelGroup

a guest
Apr 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub NetsuiteToExcelGroup()
  2.     Dim CurrentLine As Integer
  3.     Dim LastLine As Integer
  4.    
  5.     Cells.RowHeight = 18.75
  6.     Cells.EntireRow.AutoFit
  7.    
  8.     LastLine = Cells(999999, 1).End(xlUp).Row
  9.  
  10.     With ActiveSheet.Outline
  11.         .AutomaticStyles = False
  12.         .SummaryRow = xlAbove
  13.         .SummaryColumn = xlRight
  14.     End With
  15.    
  16.     i = 1
  17.    
  18.     Do While Cells(i, 1).Interior.Color <> 13684944
  19.         i = i + 1
  20.     Loop
  21.    
  22.     i = i + 1
  23.  
  24.     CurrentLine = i
  25.    
  26.     Call Group(i, CurrentLine, LastLine)
  27.    
  28. End Sub
  29.  
  30. Sub Group(ByVal StartLine As Integer, ByRef CurrentLine As Integer, ByRef LastLine As Integer)
  31.     stopper = False
  32.    
  33.     StartLine = CurrentLine
  34.     Do While stopper = False
  35.         If CurrentLine > LastLine Then
  36.             Exit Do
  37.         End If
  38.                
  39.         If Cells(CurrentLine, 1).IndentLevel < Cells(CurrentLine + 1, 1).IndentLevel Then
  40.             CurrentLine = CurrentLine + 1
  41.             Call Group(StartLine, CurrentLine, LastLine)
  42.            
  43.         ElseIf Cells(CurrentLine, 1).IndentLevel = Cells(CurrentLine + 1, 1).IndentLevel Then
  44.             CurrentLine = CurrentLine + 1
  45.         ElseIf Cells(CurrentLine, 1).IndentLevel > Cells(CurrentLine + 1, 1).IndentLevel Then
  46.             Rows(CStr(StartLine) + ":" + CStr(CurrentLine + 1)).Select
  47.             Selection.Rows.Group
  48.             If IsEmpty(Cells(StartLine - 1, 2)) Then
  49.                 Cells(StartLine - 1, 2).Formula = Cells(CurrentLine + 1, 2).Formula
  50.             End If
  51.             CurrentLine = CurrentLine + 1
  52.             Exit Do
  53.         Else
  54.             Exit Do
  55.         End If
  56.     Loop
  57.        
  58. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement