Linking of Excel using ADODB Connection

srinimeister86

New Member
Joined
Aug 3, 2011
Messages
1
hi

I am trying to copy data from one excel sheet to another using ADODB Connection. I am able to fetch the data except one field. Even if it has value it gives me empty string.

set con = new abodb.connection//First excel
set con1 = new abodb.connection//second excel
set rs = new adodb.recordset
set rs1 = new adodb.recordset //second excel
//i declared the connection string
cn.open
cn1.open
squery= "select * from [Sheet1$]"
rs1.open squery,cn1,adlockoptimistic,adopendynamic
rs.open squery,cn,adlockoptimistic,adopendynamic
rs.movefirst
do until rs.EOF
if(IsNull(rs.Fields(2)) = True) then
goto L1
else
rs1.fields(1) = rs.fields(1)
rs1.fields(2) = rs.fields(2)
rs1.fields(3) = rs.fields(3)
rs1.update
rs1.movenext
endif
L1:
rs.movenext
loop

In this case rs.Fields(2) creates the problem. If it does not has any data it return Null value and if it has data in the cell then it return "" empty string value. Kindly help me on this issue. For the rest of the fields i am getting information and for the second field i am getting empty string instead of valid data...help pn this issue
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,224,618
Messages
6,179,916
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top