XL: Visual Basic Module ? t?o ra m?t bi?u ? Gantt

D?ch tiu ? D?ch tiu ?
ID c?a bi: 213447 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

Trong Microsoft Excel, b?n c th? t?o charts Gantt hi?n th? tr?ng thi nhi?m v? ?i v?i d? n quy ho?ch v i?u khi?n. Bi vi?t ny m t? lm th? no ? l?p tr?nh t?o ra cc lo?i bi?u ? s? d?ng m?t Microsoft Visual Basic cho cc ?ng d?ng th? t?c.

THNG TIN THM

Microsoft cung c?p l?p tr?nh v d? ? minh ho? ch?, khng c b?o hnh ho?c th? hi?n hay ng? ?, bao g?m nhng khng gi?i h?n, b?o ?m ng? ? kh? nng bn hng v/ho?c cho m?t m?c ch c? th?. Bi vi?t ny gi? ?nh r?ng b?n ? quen thu?c v?i ngn ng? l?p tr?nh ?c ch?ng minh v cc cng c? ?c s? d?ng ? t?o ra v g? l?i th? t?c. Microsoft h? tr? cc chuyn gia c th? gip gi?i thch cc ch?c nng c?a m?t th? t?c c? th?, nhng h? s? khng s?a ?i cc v d? ? cung c?p thm ch?c nng ho?c xy d?ng quy tr?nh ? p ?ng nhu c?u c? th? c?a b?n.
N?u b?n c h?n ch? kinh nghi?m l?p tr?nh, b?n c th? mu?n lin h? v?i m?t Microsoft Certified Partner ho?c d?ch v? t v?n c?a Microsoft. ? bi?t thm chi ti?t, truy c?p vo cc trang Web Microsoft:

Microsoft Certified ?i tc- https://Partner.Microsoft.com/Global/30000104

D?ch v? t v?n c?a Microsoft- http://support.Microsoft.com/GP/advisoryservice

? bi?t thm v? cc ty ch?n h? tr? c s?n v v? lm th? no ? lin h? v?i Microsoft, gh thm Web site sau c?a Microsoft:http://support.Microsoft.com/Default.aspx?SCID=FH;EN-US;CNTACTMS? t?o m?t Visual Basic cho cc ?ng d?ng v? m trong Excel m b?n c th? s? d?ng ? t?o ra m?t bi?u ? Gantt, h?y lm theo cc b?c sau:
  1. Khi ng Excel.
  2. Nh?n ALT + F11 ? b?t ?u Visual Basic Editor.
  3. Trn cc Chn tr?nh n, nh?p vo M-un.
  4. G? hay dn o?n m? sau trong t? m-un Visual Basic:
    Option Explicit
     
    Sub Gantt_Chart()
        'Define the variables.
        Dim rge As String
        Dim ValueAxisMinValue As Date
        Dim shtname As String
        Dim Title As String, aChart As Chart
        'Store the location of the data as a string.
        rge = Selection.Address()
        'Store the start date for the chart.
        ValueAxisMinValue = Selection.Cells(2, 2).Value
        'Ask user for the Chart title.
        Title = InputBox("Please enter the title")
        'Store the sheet name.
        shtname = ActiveSheet.Name
        'Turn off screen updating.
        Application.ScreenUpdating = False
        'Create a chart located on a chart sheet.
        Set aChart = Charts.Add
        With aChart
            .ChartWizard Source:=Sheets(shtname).Range(rge), _
            Gallery:=xlBar, Format:=3, PlotBy:=xlColumns, _
            CategoryLabels:=1, SeriesLabels:=1, HasLegend:=1, _
            Title:=Title, CategoryTitle:="", ValueTitle:="", _
            ExtraTitle:=""
            'Remove the legend.
            .Legend.Delete
            'Create and format the series.
            With .SeriesCollection(1)
                With .Border
                    .Weight = xlThin
                    .LineStyle = xlNone
                End With
                .InvertIfNegative = False
                .Interior.ColorIndex = xlNone
            End With
            'Modify the category (x) axis.
            With .Axes(xlCategory)
                .ReversePlotOrder = True
                .TickLabelSpacing = 1
                .TickMarkSpacing = 1
                .AxisBetweenCategories = True
            End With
            'Modify the value (y) axis.
            With .Axes(xlValue)
                .MinimumScale = ValueAxisMinValue
                .MaximumScaleIsAuto = True
                .MinorUnitIsAuto = True
                .MajorUnitIsAuto = True
                .Crosses = xlAutomatic
                .ReversePlotOrder = False
                .ScaleType = False
                .HasMajorGridlines = True
                .HasMinorGridlines = False
            End With
         End With
        'Turn screen updating back on.
        Application.ScreenUpdating = True
     
     End Sub
    					
  5. Nh?n ALT + F11 ? tr? v? Excel.

B?ng cch s? d?ng v? m

? s? d?ng Gantt_chart macro, h?y lm theo cc b?c sau:
  1. Trong m?t b?ng tnh Excel m?i, nh?p cc gi tr? sau:
         A1:            B1: START        C1: DAYS          D1: DAYS
         A2: TASK       B2: DATE         C2: COMPLETED     D2: REMAINING
         A3: TASK-1     B3: 1/1/91       C3: 150           D3: 15
         A4: TASK-2     B4: 5/1/91       C4: 21            D4: 31
         A5: TASK-3     B5: 7/1/91       C5: 0             D5: 114
         A6: TASK-4     B6: 10/1/91      C6: 0             D6: 4
         A7: TASK-5     B7: 10/15/91     C7: 0             D7: 31
         A8: TASK-6     B8: 11/1/91      C8: 0             D8: 2
    					
  2. Ch?n cc t? bo A2:D8.
  3. Trn cc Cng cu tr?nh n, i?m ?n V? m, v sau nh?p vo Macro.
  4. Nh?p vo Gantt_chart, v sau nh?p vo Ch?y.
  5. Nh?p tiu ? b?ng x?p h?ng khi ?c nh?c. Bi?u ? Gantt ?c hi?n th? trn m?t t?m b?ng x?p h?ng m?i. B?n c th? thm b?t k? b? sung d?ng m b?n mu?n.

Thu?c tnh

ID c?a bi: 213447 - L?n xem xt sau cng: 20 Thang Chin 2011 - Xem xt l?i: 3.0
p d?ng
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 97 Standard Edition
T? kha:
kbhowto kbmt KB213447 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:213447

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com