How to use macro in excel?
Can i get some code to record excell data to vb?
O y, i have project in vb, and i write data in vb, then i transfer it to excell to build chart. This is my code :
Private Sub Command3_Click( )
Set ep = GetObject("C:\D ocuments and Settings\Byon 2007\My Documents\1.xls ")
Set ew = ep.sheets(1)
ew.cells(1, 1) = Label15(0).Capt ion
ew.cells(2, 1) = Label15(1).Capt ion
ew.cells(3, 1) = Label15(2).Capt ion
ew.cells(4, 1) = Label15(3).Capt ion
ew.cells(5, 1) = Label15(4).Capt ion
ew.cells(1, 2) = Label27(0).Capt ion
ew.cells(2, 2) = Label27(1).Capt ion
ew.cells(3, 2) = Label27(2).Capt ion
ew.cells(4, 2) = Label27(3).Capt ion
ew.cells(5, 2) = Label27(4).Capt ion
ew.cells(1, 3) = Text12(0).Text
ew.cells(2, 3) = Text12(1).Text
ew.cells(3, 3) = Text12(2).Text
ew.cells(4, 3) = Text12(3).Text
ew.cells(5, 3) = Text12(4).Text
ew.cells(1, 4) = Label24(0).Capt ion
ew.cells(2, 4) = Label24(1).Capt ion
ew.cells(3, 4) = Label24(2).Capt ion
ew.cells(4, 4) = Label24(3).Capt ion
ew.cells(5, 4) = Label24(4).Capt ion
ew.cells(1, 5) = Label23(0).Capt ion
ew.cells(2, 5) = Label23(1).Capt ion
ew.cells(3, 5) = Label23(2).Capt ion
ew.cells(4, 5) = Label23(3).Capt ion
ew.cells(5, 5) = Label23(4).Capt ion
ew.cells(1, 6) = Label17(0).Capt ion
ew.cells(2, 6) = Label17(1).Capt ion
ew.cells(3, 6) = Label17(2).Capt ion
ew.cells(4, 6) = Label17(3).Capt ion
ew.cells(5, 6) = Label17(4).Capt ion
ep.application. Visible = True
End Sub
what is wrong with this code? Coz the application is not visible when i click the command button.
As u know, i want to change my data in vb and when i click this command button, the application and the chart in excell is visible and change itself according to data in vb....
Thanks for your help.
Can i get some code to record excell data to vb?
O y, i have project in vb, and i write data in vb, then i transfer it to excell to build chart. This is my code :
Private Sub Command3_Click( )
Set ep = GetObject("C:\D ocuments and Settings\Byon 2007\My Documents\1.xls ")
Set ew = ep.sheets(1)
ew.cells(1, 1) = Label15(0).Capt ion
ew.cells(2, 1) = Label15(1).Capt ion
ew.cells(3, 1) = Label15(2).Capt ion
ew.cells(4, 1) = Label15(3).Capt ion
ew.cells(5, 1) = Label15(4).Capt ion
ew.cells(1, 2) = Label27(0).Capt ion
ew.cells(2, 2) = Label27(1).Capt ion
ew.cells(3, 2) = Label27(2).Capt ion
ew.cells(4, 2) = Label27(3).Capt ion
ew.cells(5, 2) = Label27(4).Capt ion
ew.cells(1, 3) = Text12(0).Text
ew.cells(2, 3) = Text12(1).Text
ew.cells(3, 3) = Text12(2).Text
ew.cells(4, 3) = Text12(3).Text
ew.cells(5, 3) = Text12(4).Text
ew.cells(1, 4) = Label24(0).Capt ion
ew.cells(2, 4) = Label24(1).Capt ion
ew.cells(3, 4) = Label24(2).Capt ion
ew.cells(4, 4) = Label24(3).Capt ion
ew.cells(5, 4) = Label24(4).Capt ion
ew.cells(1, 5) = Label23(0).Capt ion
ew.cells(2, 5) = Label23(1).Capt ion
ew.cells(3, 5) = Label23(2).Capt ion
ew.cells(4, 5) = Label23(3).Capt ion
ew.cells(5, 5) = Label23(4).Capt ion
ew.cells(1, 6) = Label17(0).Capt ion
ew.cells(2, 6) = Label17(1).Capt ion
ew.cells(3, 6) = Label17(2).Capt ion
ew.cells(4, 6) = Label17(3).Capt ion
ew.cells(5, 6) = Label17(4).Capt ion
ep.application. Visible = True
End Sub
what is wrong with this code? Coz the application is not visible when i click the command button.
As u know, i want to change my data in vb and when i click this command button, the application and the chart in excell is visible and change itself according to data in vb....
Thanks for your help.
Comment