method 'cells' of object '_global' failed

Joined
Aug 6, 2009
Messages
1
Reaction score
0
Dear sir

I am getting error while running the vb code .... the error is "method 'cells' of object '_global' failed"

in the code i am copying the value of cell of one sheet to another sheet cell..

Please help me..

The code is...

Dim db1 As New ADODB.Connection
Dim db2 As New ADODB.Connection
Dim db3 As New ADODB.Connection
Dim db4 As New ADODB.Connection

Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
Dim rs4 As New ADODB.Recordset

Dim wb1, wb2, wb3, WB4 As Excel.Workbook
Dim ww As Excel.Workbooks
Dim ws1, ws2, ws3, WS4 As Excel.Worksheet
Dim rcnt, i As Integer


Private Sub Form_Load()
Dim rpttd, rptfd, rpt_dly_name, t_str, d_str, st_date, dt_str As String
On Error GoTo DESCR
rpttd = Format(Date, "dd/mm/yyyy")
Me.Show
Me.Refresh
Label1.Caption = "Started extraction of data"
Me.Refresh
rptfd = Format(DateAdd("d", -1, rpttd), "yyyymmdd")
Set wb1 = Excel.Workbooks.Open("z:\corex_1\templates\pcm_format.xls")
rpt_dly_name = "jin1_" & rptfd & ".xls"
Set wb2 = Excel.Workbooks.Open("z:\corex_1\daily\" & rpt_dly_name)
rpt_dly_name = "jin2_" & rptfd & ".xls"
Set wb3 = Excel.Workbooks.Open("z:\corex_2\daily\" & rpt_dly_name)
rpt_dly_name = "JINBF1_" & rptfd & ".xls"
Set WB4 = Excel.Workbooks.Open("z:\BLASTFURNACE\DAILY\" & rpt_dly_name)
rpt_dly_name = "JINBF2_" & rptfd & ".xls"
Set wb5 = Excel.Workbooks.Open("z:\BLASTFURNACE_2\DAILY\" & rpt_dly_name)

st_date = "01/" & Format(Date, "mm/yyyy")

db1.Open "Provider=MSDAORA.1;Password=corex1;User ID=corex1;Data Source=jin001_db1;Persist Security Info=True"
db2.Open "Provider=MSDAORA.1;Password=corex2;User ID=corex2;Data Source=jin002_db2;Persist Security Info=True"
db3.Open "Provider=MSDAORA.1;Password=oracle;User ID=administrator;Data Source=bf1;Persist Security Info=True"
db4.Open "Provider=MSDAORA.1;Password=corex2;User ID=corex2;Data Source=bf2;Persist Security Info=True"

Set ws1 = wb1.Worksheets("data")
Set ws2 = wb2.Worksheets("DAILY")
Set ws3 = wb3.Worksheets("DAILY")
Set WS4 = WB4.Worksheets("Daily report")
Set WS5 = wb5.Worksheets("Daily report")

ws1.Activate
ws2.Activate
ws3.Activate
WS4.Activate
WS5.Activate

///////// HERE I am GETTING ERROR
ws1.Cells(3, "b").Value = ws2.Cells(14, "E").Value + ws2.Cells(15, "E").Value
ws1.Cells(4, "b").Value = ws3.Cells(14, "E").Value + ws3.Cells(15, "E").Value
ws1.Cells(5, "b").Value = WS4.Cells(10, "E").Value
ws1.Cells(6, "b").Value = WS5.Cells(10, "E").Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top