본문 바로가기

Abap

[Abap-Excel] 엑셀에 데이터 넘기기 2 (매크로) - 엑셀부분

Public Sub work()
 Sub_work
End Sub

 

Sub Sub_work()
 Dim ITAB As Object
 Dim LV_Tcnt, LV_DAYNUM, lv_chrnum As Integer
 Dim LV_X, LV_Y, LV_Z, LV_AUFNR, LV_TEMP As String
 Dim LV_SHT, lv_idx As Integer
 Dim lv_sht_1, lv_idx_1 As Integer
 
 If ThisWorkbook.Container.Linkserver.Items("ITAB").Table Is Nothing Then
  Exit Sub
 Else
 
  Set ITAB = ThisWorkbook.Container.Linkserver.Items("ITAB").Table
 
' Total count
  LV_Tcnt = ThisWorkbook.Container.Linkserver.Items("ITAB").Table.RowCount
 
 
   Sheets(1).Select
'=> Value
   With ThisWorkbook.Sheets(1)
     LV_SHT = 28
     For lv_idx = 1 To LV_Tcnt
       
       LV_Z = "B" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 35))
      
       LV_Z = "C" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 36))
    
       LV_Z = "F" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 1))
    
       LV_Z = "G" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 2))
    
       LV_Z = "H" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 3))
    
       LV_Z = "I" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 4))
    
       LV_Z = "J" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 5))
    
       LV_Z = "K" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 6))
    
       LV_Z = "L" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 7))
    
       LV_Z = "M" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 8))
    
       LV_Z = "N" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 9))
    
       LV_Z = "O" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 10))
      
      
      
              LV_Z = "P" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 11))
      
              LV_Z = "Q" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 12))
      
              LV_Z = "R" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 13))
      
              LV_Z = "S" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 14))
      
              LV_Z = "T" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 15))
      
              LV_Z = "U" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 16))
      
              LV_Z = "V" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 17))
      
              LV_Z = "W" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 18))
      
              LV_Z = "X" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 19))
      
              LV_Z = "Y" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 20))
      
              LV_Z = "Z" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 21))
      
              LV_Z = "AA" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 22))
      
              LV_Z = "AB" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 23))
      
              LV_Z = "AC" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 24))
      
              LV_Z = "AD" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 25))
      
              LV_Z = "AE" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 26))
      
              LV_Z = "AF" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 27))
      
              LV_Z = "AG" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 28))
      
              LV_Z = "AH" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 29))
      
              LV_Z = "AI" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 30))
      
              LV_Z = "AJ" & (lv_idx + LV_SHT)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(lv_idx, 31))
      
     Next lv_idx
    
       
       LV_Z = "D" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 38))
      
       LV_Z = "D" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 39))
      
       LV_Z = "D" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 40))
      
       LV_Z = "D" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 41))
      
            
            
       LV_Z = "G" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 42))
      
       LV_Z = "G" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 43))
      
       LV_Z = "G" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 44))
      
       LV_Z = "G" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 45))
      
      
      
       LV_Z = "K" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 46))
      
       LV_Z = "K" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 47))
      
       LV_Z = "K" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 48))
      
       LV_Z = "K" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 49))
      
      
         
       LV_Z = "O" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 50))
      
       LV_Z = "O" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 51))
      
       LV_Z = "O" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 52))
      
       LV_Z = "O" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 53))
      
      
      
       LV_Z = "S" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 54))
      
       LV_Z = "S" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 55))
      
       LV_Z = "S" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 56))
      
       LV_Z = "S" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 57))
      
      
      
       LV_Z = "W" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 58))
      
       LV_Z = "W" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 59))
      
       LV_Z = "W" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 60))
      
       LV_Z = "W" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 61))
      
      
      
       LV_Z = "AA" & (4)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(1, 62))
      
       LV_Z = "AA" & (5)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(2, 63))
      
       LV_Z = "AA" & (6)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(3, 64))
      
       LV_Z = "AA" & (7)
       Range(LV_Z).Select
       ActiveCell.FormulaR1C1 = CVar(ITAB.Value(4, 65))
      
   
   End With
 End If
 
End Sub