SHARE
TWEET

Input Data Ke Sheet Excel Secara Multiple Sheet Coba

stevennathaniel Jan 31st, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports Excel = Microsoft.Office.Interop.Excel
  2.  
  3. Imports Microsoft.Office
  4.  
  5. Public Class Form11
  6.  
  7.     Dim appXL As Excel.Application = Nothing
  8.  
  9.     Dim wbXL As Excel.Workbook = Nothing
  10.  
  11.     Dim shXL As Excel.Worksheet = Nothing
  12.  
  13.     Dim raXL As Excel.Range = Nothing
  14.  
  15.     Dim i As Integer
  16.  
  17.     Dim j As Integer
  18.  
  19.     Dim k As Integer
  20.  
  21.     Dim nomerSheet As Integer
  22.  
  23.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  24.  
  25.  
  26.         appXL = New Excel.Application
  27.  
  28.         wbXL = appXL.Workbooks.Open("D:\fileExcel\Latihan100.xlsx")
  29.  
  30.         appXL.Visible = True
  31.  
  32.         For i = 5 To 7
  33.  
  34.             nomerSheet = i
  35.  
  36.             With wbXL
  37.  
  38.                 .Worksheets.Add(After:=.Worksheets(nomerSheet))
  39.  
  40.  
  41.             End With
  42.  
  43.         Next
  44.  
  45.  
  46.  
  47.         'Pilih Wosksheet urutan ke 5 dari kiri dan isi nilai cell nya
  48.  
  49.         shXL = wbXL.Worksheets(5)
  50.  
  51.         'shXL.Name = namaSheetBaru
  52.  
  53.         For k = 1 To 6
  54.  
  55.             For j = 1 To 2
  56.  
  57.                 shXL.Cells(k, j) = 200
  58.  
  59.             Next j
  60.         Next k
  61.  
  62.  
  63.  
  64.  
  65.         appXL.UserControl = True
  66.  
  67.         raXL = Nothing
  68.  
  69.         wbXL = Nothing
  70.  
  71.         shXL = Nothing
  72.  
  73.         appXL = Nothing
  74.  
  75.  
  76.         Exit Sub
  77.  
  78. Err_Handler:
  79.  
  80.         MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
  81.  
  82.  
  83.  
  84.     End Sub
  85. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top