Hi,
I want to export data from listbox into an excel app.
excel.Range("C23").Value=" New product"
excel.Range("C24").Value=" Reject"
excel.Range("C25").Value=" No Attrib"
excel.Range("C26").Value=" New year"
this code is running and work, but the problem is I have to define which cell will be inserted.
I cant calculate how many rows in Listbox, because its depend to a user.
I tried to modificate it into,
[code]excel.Range("C" + Str(i + 3)).value = " New product"
excel.Range("C" + Str(i + 3)).value = " Reject"
excel.Range("C" + Str(i + 3)).value = " No Attrib"
excel.Range("C" + Str(i + 3)).value = " New year"[/code]
but it won’t follow the last rows of listbox exported.
this is the code of exporting process into excel.
[code] excel.Range(“G3:G100”).HorizontalAlignment=4 'right
excel.Range(“A2”).Value = LstMasuk.heading(0)
excel.Range(“B2”).Value = LstMasuk.heading(1)
excel.Range(“C2”).Value = LstMasuk.heading(2)
excel.Range(“D2”).Value =LstMasuk.heading(3)
excel.Range(“E2”).Value = LstMasuk.heading(4)
excel.Range(“F2”).Value =LstMasuk.heading(5)
excel.Range(“G2”).Value =LstMasuk.heading(6)
excel.Range(“H2”).Value =LstMasuk.heading(7)
excel.Range(“I2”).Value =LstMasuk.heading(8)
excel.Range(“J2”).Value =LstMasuk.heading(9)
excel.Range(“K2”).Value =LstMasuk.heading(10)
excel.Range(“L2”).Value =LstMasuk.heading(11)
excel.Range(“M2”).Value =LstMasuk.heading(12)
excel.Range(“N2”).Value =LstMasuk.heading(13)
excel.Range(“O2”).Value =LstMasuk.heading(14)
excel.Range("A2:O2").Font.Bold=true
excel.Range("A2:O2").Interior.ColorIndex=2
excel.Range("A2:O2").Borders.LineStyle=1
excel.Range("A2:"+"O"+str(i+3)).Borders.LineStyle=1
excel.Range("A2:O2").interior.ColorIndex=56'dark grey
excel.Range("A" + Str(i + 3), "A" + Str(i + 3)).value = lstMasuk.cell(i, 0)
excel.Range("B" + Str(i + 3), "B" + Str(i + 3)).value =lstMasuk.cell(i, 1)
excel.Range("C" + Str(i + 3), "C" + Str(i + 3)).value = lstMasuk.cell(i, 2)
excel.Range("D" + Str(i +3), "D" + Str(i + 3)).value =lstMasuk.cell(i, 3)
excel.Range("E" + Str(i + 3), "E" + Str(i + 3)).value = lstMasuk.cell(i, 4)
excel.Range("F" + Str(i + 3), "F" + Str(i + 3)).value = lstMasuk.cell(i, 5)
excel.Range("G" + Str(i + 3), "G" + Str(i + 3)).value =lstMasuk.cell(i, 6)
excel.Range("H" + Str(i + 3), "H" + Str(i + 3)).value =lstMasuk.cell(i, 7)
excel.Range("I" + Str(i + 3), "I" + Str(i + 3)).value =lstMasuk.cell(i, 8)
excel.Range("J" + Str(i + 3), "J" + Str(i + 3)).value = lstMasuk.cell(i, 9)
excel.Range("K" + Str(i + 3), "K" + Str(i + 3)).value = lstMasuk.cell(i, 10)
excel.Range("L" + Str(i + 3), "L" + Str(i + 3)).value = lstMasuk.cell(i, 11)
excel.Range("M" + Str(i + 3), "M" + Str(i + 3)).value = lstMasuk.cell(i, 12)[/code]
any helps?
thanks
arief