Tecnologia, programação e muito Visual FoxPro.

terça-feira, 16 de outubro de 2012

]] XL-mania [[ print database dari worksheet lain dengan VBA

 

Dear milist,

Saya sedang punya project untuk membuat database dari excel dengan data
yang berada pada worksheet lain, dan form untuk print pada worksheet
yang lain juga. Saya mencoba dengan VBA dengan kode:

'----------------------------------------------------------\
------------------
Private Sub UserForm_Initialize()
Dim mycell As Range
Dim wsdatabaseNG As Worksheet
Set wsdatabaseNG = Sheets("VibDataNG")

For Each mycell In wsdatabaseNG.Range("DateNG")
With Me.ComboTanggal
.AddItem mycell.Value
.List(.ListCount - 1, 1) = mycell.Offset(0, 1).Value
End With

Next mycell

End Sub
'----------------------------------------------------------\
------------
Private Sub PrintNG_Click()
Dim UserInput As String
Dim userdata As String
Dim mycell As Range
Dim xRow As Integer
Dim Lcolumn As Integer

UserInput = ComboTanggal.Text

If UserInput = "" Then End

On Error Resume Next

userdata = UserInput
If Err.Number = 13 Then MsgBox "Maaf, Anda tidak memasukan tanggal
dengan benar": End

On Error GoTo 0

For Each mycell In ActiveSheet.UsedRange

If mycell.Cells.Value = userdata Then
mycell.Select
xRow = mycell.Row
Lcolumn = mycell.Column
End If
Next
'Memasukan data vibrasi ke worksheet PrintNG
On Error Resume Next
Worksheets("PrintNG").Range("E10").Value = Cells(xRow, 2).Value
Worksheets("PrintNG").Range("E9").Value = Cells(xRow, 3).Value
Worksheets("PrintNG").Range("E15").Value = Cells(xRow, 4).Value
Worksheets("PrintNG").Range("E16").Value = Cells(xRow, 5).Value
Worksheets("PrintNG").Range("H15").Value = Cells(xRow, 6).Value
Worksheets("PrintNG").Range("C17").Value = Cells(xRow, 7).Value
Worksheets("PrintNG").Range("C18").Value = Cells(xRow, 8).Value
Worksheets("PrintNG").Range("H17").Value = Cells(xRow, 9).Value
Worksheets("PrintNG").Range("H18").Value = Cells(xRow, 10).Value
Worksheets("PrintNG").Range("C19").Value = Cells(xRow, 11).Value
Worksheets("PrintNG").Range("C20").Value = Cells(xRow, 12).Value
Worksheets("PrintNG").Range("C21").Value = Cells(xRow, 13).Value
Worksheets("PrintNG").Range("G21").Value = Cells(xRow, 14).Value
'----------------------------------------------------------\
----------
Worksheets("PrintNG").Range("C25").Value = Cells(xRow, 15).Value
Worksheets("PrintNG").Range("E25").Value = Cells(xRow, 16).Value
Worksheets("PrintNG").Range("F25").Value = Cells(xRow, 17).Value
Worksheets("PrintNG").Range("G25").Value = Cells(xRow, 18).Value
Worksheets("PrintNG").Range("H25").Value = Cells(xRow, 19).Value
Worksheets("PrintNG").Range("I25").Value = Cells(xRow, 20).Value
Worksheets("PrintNG").Range("J25").Value = Cells(xRow, 21).Value
Worksheets("PrintNG").Range("K25").Value = Cells(xRow, 22).Value
Worksheets("PrintNG").Range("L25").Value = Cells(xRow, 23).Value
Worksheets("PrintNG").Range("M25").Value = Cells(xRow, 24).Value
Worksheets("PrintNG").Range("Q25").Value = Cells(xRow, 25).Value
Worksheets("PrintNG").Range("S25").Value = Cells(xRow, 26).Value
Worksheets("PrintNG").Range("T25").Value = Cells(xRow, 27).Value
Worksheets("PrintNG").Range("C26").Value = Cells(xRow, 28).Value
Worksheets("PrintNG").Range("E26").Value = Cells(xRow, 29).Value
Worksheets("PrintNG").Range("F26").Value = Cells(xRow, 30).Value
Worksheets("PrintNG").Range("G26").Value = Cells(xRow, 31).Value
Worksheets("PrintNG").Range("H26").Value = Cells(xRow, 32).Value
Worksheets("PrintNG").Range("I26").Value = Cells(xRow, 33).Value
Worksheets("PrintNG").Range("J26").Value = Cells(xRow, 34).Value
Worksheets("PrintNG").Range("K26").Value = Cells(xRow, 35).Value
Worksheets("PrintNG").Range("L26").Value = Cells(xRow, 36).Value
Worksheets("PrintNG").Range("Q26").Value = Cells(xRow, 37).Value
Worksheets("PrintNG").Range("S26").Value = Cells(xRow, 38).Value
Worksheets("PrintNG").Range("T26").Value = Cells(xRow, 39).Value

'----------------------------------------------------------\
------
Worksheets("PrintNG").Range("C27").Value = Cells(xRow, 40).Value
Worksheets("PrintNG").Range("E27").Value = Cells(xRow, 41).Value
Worksheets("PrintNG").Range("F27").Value = Cells(xRow, 42).Value
Worksheets("PrintNG").Range("G27").Value = Cells(xRow, 43).Value
Worksheets("PrintNG").Range("H27").Value = Cells(xRow, 44).Value
Worksheets("PrintNG").Range("I27").Value = Cells(xRow, 45).Value
Worksheets("PrintNG").Range("J27").Value = Cells(xRow, 46).Value
Worksheets("PrintNG").Range("K27").Value = Cells(xRow, 47).Value
Worksheets("PrintNG").Range("L27").Value = Cells(xRow, 48).Value
Worksheets("PrintNG").Range("M27").Value = Cells(xRow, 49).Value
Worksheets("PrintNG").Range("Q27").Value = Cells(xRow, 50).Value
Worksheets("PrintNG").Range("S27").Value = Cells(xRow, 51).Value
Worksheets("PrintNG").Range("T27").Value = Cells(xRow, 52).Value
Worksheets("PrintNG").Range("C28").Value = Cells(xRow, 53).Value
Worksheets("PrintNG").Range("E28").Value = Cells(xRow, 54).Value
Worksheets("PrintNG").Range("F28").Value = Cells(xRow, 55).Value
Worksheets("PrintNG").Range("G28").Value = Cells(xRow, 56).Value
Worksheets("PrintNG").Range("H28").Value = Cells(xRow, 57).Value
Worksheets("PrintNG").Range("I28").Value = Cells(xRow, 58).Value
Worksheets("PrintNG").Range("J28").Value = Cells(xRow, 59).Value
Worksheets("PrintNG").Range("K28").Value = Cells(xRow, 60).Value
Worksheets("PrintNG").Range("L28").Value = Cells(xRow, 61).Value
Worksheets("PrintNG").Range("Q28").Value = Cells(xRow, 62).Value
Worksheets("PrintNG").Range("S28").Value = Cells(xRow, 63).Value
Worksheets("PrintNG").Range("T28").Value = Cells(xRow, 64).Value

'----------------------------------------------------------\
-------
Worksheets("PrintNG").Range("E29").Value = Cells(xRow, 65).Value
Worksheets("PrintNG").Range("F29").Value = Cells(xRow, 66).Value
Worksheets("PrintNG").Range("M29").Value = Cells(xRow, 67).Value
Worksheets("PrintNG").Range("N29").Value = Cells(xRow, 68).Value
Worksheets("PrintNG").Range("O29").Value = Cells(xRow, 69).Value
Worksheets("PrintNG").Range("P29").Value = Cells(xRow, 70).Value
Worksheets("PrintNG").Range("Q29").Value = Cells(xRow, 71).Value
Worksheets("PrintNG").Range("R29").Value = Cells(xRow, 72).Value
Worksheets("PrintNG").Range("S29").Value = Cells(xRow, 73).Value
Worksheets("PrintNG").Range("T29").Value = Cells(xRow, 74).Value

'----------------------------------------------------------\
-------
Worksheets("PrintNG").Range("C30").Value = Cells(xRow, 75).Value
Worksheets("PrintNG").Range("E30").Value = Cells(xRow, 76).Value
Worksheets("PrintNG").Range("F30").Value = Cells(xRow, 77).Value
Worksheets("PrintNG").Range("G30").Value = Cells(xRow, 78).Value
Worksheets("PrintNG").Range("H30").Value = Cells(xRow, 79).Value
Worksheets("PrintNG").Range("I30").Value = Cells(xRow, 80).Value
Worksheets("PrintNG").Range("J30").Value = Cells(xRow, 81).Value
Worksheets("PrintNG").Range("K30").Value = Cells(xRow, 82).Value
Worksheets("PrintNG").Range("L30").Value = Cells(xRow, 83).Value
Worksheets("PrintNG").Range("M30").Value = Cells(xRow, 84).Value
Worksheets("PrintNG").Range("Q30").Value = Cells(xRow, 85).Value
Worksheets("PrintNG").Range("S30").Value = Cells(xRow, 86).Value
Worksheets("PrintNG").Range("T30").Value = Cells(xRow, 87).Value
Worksheets("PrintNG").Range("C31").Value = Cells(xRow, 88).Value
Worksheets("PrintNG").Range("E31").Value = Cells(xRow, 89).Value
Worksheets("PrintNG").Range("F31").Value = Cells(xRow, 90).Value
Worksheets("PrintNG").Range("G31").Value = Cells(xRow, 91).Value
Worksheets("PrintNG").Range("H31").Value = Cells(xRow, 92).Value
Worksheets("PrintNG").Range("I31").Value = Cells(xRow, 93).Value
Worksheets("PrintNG").Range("J31").Value = Cells(xRow, 94).Value
Worksheets("PrintNG").Range("K31").Value = Cells(xRow, 95).Value
Worksheets("PrintNG").Range("L31").Value = Cells(xRow, 96).Value
Worksheets("PrintNG").Range("Q31").Value = Cells(xRow, 97).Value
Worksheets("PrintNG").Range("S31").Value = Cells(xRow, 98).Value
Worksheets("PrintNG").Range("T31").Value = Cells(xRow, 99).Value

'----------------------------------------------------------\
-------
Worksheets("PrintNG").Range("C32").Value = Cells(xRow, 100).Value
Worksheets("PrintNG").Range("E32").Value = Cells(xRow, 101).Value
Worksheets("PrintNG").Range("F32").Value = Cells(xRow, 102).Value
Worksheets("PrintNG").Range("G32").Value = Cells(xRow, 103).Value
Worksheets("PrintNG").Range("H32").Value = Cells(xRow, 104).Value
Worksheets("PrintNG").Range("I32").Value = Cells(xRow, 105).Value
Worksheets("PrintNG").Range("J32").Value = Cells(xRow, 106).Value
Worksheets("PrintNG").Range("K32").Value = Cells(xRow, 107).Value
Worksheets("PrintNG").Range("L32").Value = Cells(xRow, 108).Value
Worksheets("PrintNG").Range("M32").Value = Cells(xRow, 109).Value
Worksheets("PrintNG").Range("Q32").Value = Cells(xRow, 110).Value
Worksheets("PrintNG").Range("S32").Value = Cells(xRow, 111).Value
Worksheets("PrintNG").Range("T32").Value = Cells(xRow, 112).Value
Worksheets("PrintNG").Range("C33").Value = Cells(xRow, 113).Value
Worksheets("PrintNG").Range("E33").Value = Cells(xRow, 114).Value
Worksheets("PrintNG").Range("F33").Value = Cells(xRow, 115).Value
Worksheets("PrintNG").Range("G33").Value = Cells(xRow, 116).Value
Worksheets("PrintNG").Range("H33").Value = Cells(xRow, 117).Value
Worksheets("PrintNG").Range("I33").Value = Cells(xRow, 118).Value
Worksheets("PrintNG").Range("J33").Value = Cells(xRow, 119).Value
Worksheets("PrintNG").Range("K33").Value = Cells(xRow, 120).Value
Worksheets("PrintNG").Range("L33").Value = Cells(xRow, 121).Value
Worksheets("PrintNG").Range("Q33").Value = Cells(xRow, 122).Value
Worksheets("PrintNG").Range("S33").Value = Cells(xRow, 123).Value
Worksheets("PrintNG").Range("T33").Value = Cells(xRow, 124).Value

'----------------------------------------------------------\
------
Worksheets("PrintNG").Range("E34").Value = Cells(xRow, 125).Value
Worksheets("PrintNG").Range("F34").Value = Cells(xRow, 126).Value
Worksheets("PrintNG").Range("M34").Value = Cells(xRow, 127).Value
Worksheets("PrintNG").Range("O34").Value = Cells(xRow, 128).Value
Worksheets("PrintNG").Range("Q34").Value = Cells(xRow, 129).Value
Worksheets("PrintNG").Range("R34").Value = Cells(xRow, 130).Value
Worksheets("PrintNG").Range("S34").Value = Cells(xRow, 131).Value
Worksheets("PrintNG").Range("T34").Value = Cells(xRow, 132).Value

'----------------------------------------------------------\
------
Worksheets("PrintNG").Range("B38").Value = Cells(xRow, 133).Value
Worksheets("PrintNG").Range("B39").Value = Cells(xRow, 134).Value
Worksheets("PrintNG").Range("B40").Value = Cells(xRow, 135).Value
Worksheets("PrintNG").Range("B41").Value = Cells(xRow, 136).Value
Worksheets("PrintNG").Range("B42").Value = Cells(xRow, 137).Value

Worksheets("PrintNG").PrintOut Preview = True, Collate = True,
PrToFileName = True
End Sub

Apa kode diatas sudah benar? soalnya saya debug sudak OK, tetapi ketika
dijalankan tidak ada data yang terambil dari database.

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
+-:: XL-mania ::::::::::::::::::::----------------------------------+
| Selamat jalan SitiVi, semoga bahagia di sisi-Nya...               |
| Maaf moderasi lemooOooOott... momods siboek                       |
+-------------------------------------------------------------------+
| DILARANG : MLM, money game, OOT, iklan tanpa izin, SARA, testing, |
| pembicaraan pribadi, one line message,  melecehkan,  tidak sopan. |
+-------------------------------------------------------------------+
| Buat subjek yang kreatif, jangan : "tanya", "help", "mohon bantu" |
| Usahakan besar attachment < 200 kb. Gunakan  winzip  jika  perlu. |
+-------------------------------------------------------------------+
| Ajak teman-teman Anda bergabung dengan mengirim e-mail kosong ke  |
| XL-mania-subscribe@yahoogroups.com atau kirimkan mereka file dari |
| http://groups.yahoo.com/group/XL-mania/files/Promotion/           |
+-------------------------------------------------------------------+
| Berikan testimoni di :                                            |
| http://www.xl-mania.com/2008/06/testimoni-xl-mania.html           |
+-------------------------------------------------------------------+
| Message lama ada di :                                             |
| http://groups.yahoo.com/group/XL-mania/messages [perlu yahoo id]  |
| http://www.mail-archive.com/xl-mania@yahoogroups.com              |
+-------------------------------------------------------------------+
.

__,_._,___

Nenhum comentário:

Arquivo do blog