Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Excel = Microsoft.Office.Interop.Excel
- Imports Microsoft.Office
- Public Class Form11
- Dim appXL As Excel.Application = Nothing
- Dim wbXL As Excel.Workbook = Nothing
- Dim shXL As Excel.Worksheet = Nothing
- Dim raXL As Excel.Range = Nothing
- Dim i As Integer
- Dim j As Integer
- Dim k As Integer
- Dim nomerSheet As Integer
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- appXL = New Excel.Application
- wbXL = appXL.Workbooks.Open("D:\fileExcel\Latihan100.xlsx")
- appXL.Visible = True
- For i = 5 To 7
- nomerSheet = i
- With wbXL
- .Worksheets.Add(After:=.Worksheets(nomerSheet))
- End With
- Next
- 'Pilih Wosksheet urutan ke 5 dari kiri dan isi nilai cell nya
- shXL = wbXL.Worksheets(5)
- 'shXL.Name = namaSheetBaru
- For k = 1 To 6
- For j = 1 To 2
- shXL.Cells(k, j) = 200
- Next j
- Next k
- appXL.UserControl = True
- raXL = Nothing
- wbXL = Nothing
- shXL = Nothing
- appXL = Nothing
- Exit Sub
- Err_Handler:
- MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement