SHARE
TWEET

Untuk MS Excel, For Next dengan 2 Variabel

stevennathaniel Jan 27th, 2016 56 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.  
  6. Public Class Form7
  7.  
  8.     Dim appXL As Excel.Application = Nothing
  9.  
  10.     Dim wbXL As Excel.Workbook = Nothing
  11.  
  12.     Dim shXL As Excel.Worksheet = Nothing
  13.  
  14.     Dim raXL As Excel.Range = Nothing
  15.  
  16.     Dim i As Integer
  17.  
  18.     Dim j As Integer
  19.  
  20.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  21.  
  22.         appXL = New Excel.Application
  23.  
  24.         wbXL = appXL.Workbooks.Open("D:\fileExcel\Latihan100.xlsx")
  25.  
  26.         shXL = wbXL.Worksheets("Sheet2")
  27.  
  28.         shXL.Activate()
  29.  
  30.         appXL.Visible = True
  31.  
  32.         For i = 1 To 6
  33.  
  34.             For j = 1 To 2
  35.  
  36.                 shXL.Cells(i, j) = 200
  37.  
  38.             Next j
  39.         Next i
  40.  
  41.  
  42.  
  43.         appXL.UserControl = True
  44.  
  45.         raXL = Nothing
  46.  
  47.         wbXL = Nothing
  48.  
  49.         shXL = Nothing
  50.  
  51.         appXL = Nothing
  52.  
  53.         Exit Sub
  54.  
  55.  
  56. Err_Handler:
  57.  
  58.         MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
  59.  
  60.  
  61.  
  62.  
  63.     End Sub
  64. 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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top