Excel created in VB

Source: Internet
Author: User
Tags integer range
excel| Create I'm using DAO. Import data from the database into the Excel object you created

Sub tabletoexcel (ntablename As Integer, Ntabledata () As Integer)
Frmquartertable.mousepointer = 11
On Error Resume Next
Dim I as Integer
Dim J as Integer
Dim Stryear as String
Dim Strseason as String
Dim xlapp, Xlbook, xlsheet as Object
On Error Resume Next
Set xlapp = CreateObject ("Excel.Application")
Set xlbook = XlApp.Workbooks.Add
Set xlsheet1 = xlbook.worksheets (1)
XlApp.activewindow.tabratio = 0.9
Select Case Ntablename
Case 11:
Xlbook.worksheets ("Sheet1"). Select
XlApp.activesheet.range ("B1:h1"). Select
XLAPP.ACTIVECELL.FORMULAR1C1 = "Table 1-1"

XlApp.selection.Font.Name = "Blackbody"
XlApp.selection.Font.FontStyle = "Bold"
XlApp.selection.Font.Size = 18
XlApp.selection.merge
With XlApp.activesheet.range ("a2:i13"). Borders ' Border settings
. LineStyle = 1 ' xlborderlinestylecontinuous
. ColorIndex = 5 ' border is black =1

Blue =5
. Weight = 2 ' xlthin
End With
With Xlbook.worksheets ("Sheet1")
. Cells (2, 3) = "New Patient (1)":. Cells (2, 4) = "Relapse (2)":

. Cells (2, 5) = "Recovery (3)":

. Cells (2, 6) = "Initial treatment failure (4)":. Cells (2, 7) = "Moved in

(5) ":

. Cells (2, 8) = "Other (6)":. Cells (2, 9) = "Total (7)"
. Cells (3, 2) = "Primary treatment":. Cells (6, 2) = "First rule":. Cells (9,

2) = "First Rule"
. Cells (4, 2) = "Re-treatment":. Cells (7, 2) = "Re-treatment":. Cells

(10, 2) = "Re-treatment"
. Cells (5, 2) = "Subtotal":. Cells (8, 2) = "Subtotal":. Cells

(11, 2) = "Subtotal"
. Cells (2, 1) = "":. Range ("A2:b2"). Select:

XlApp.selection.merge
. Cells (3, 1) = "Tu Yang":. Range ("A3:a5"). Select:

XlApp.selection.merge
. Cells (6, 1) = "Smear yin":. Range ("A6:a8"). Select:

XlApp.selection.merge
. Cells (9, 1) = "No sputum checked":. Range ("A9:a11"). Select:

XlApp.selection.merge
. Cells (12, 1) = "pleurisy":. Range ("A12:b12"). Select:

XlApp.selection.merge
. Cells (13, 1) = "Other":. Range ("A13:b13"). Select:

XlApp.selection.merge
. Columns ("F:f"). ColumnWidth = 13
. Range ("A1:i13"). Select
With Xlapp.selection
. HorizontalAlignment =-4108 ' horizontal habitat

In
. VerticalAlignment =-4108 ' Vertical habitat

In
End With
For i = 3 to 13
For j = 3 to 9
. Cells (i, j) = Ntabledata (I-1, J)
Next
Next
End With
Case 12: .........

Case 13: .............

End Select

For i = 0 to 12
For j = 0 to 11
Ntabledata (i, j) = 0
Next
Next
Xlapp.visible = True
Frmquartertable.mousepointer = 1

End Sub





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.