Updates only first ROW from Excel

bharatvly

Board Regular
Joined
Jun 3, 2014
Messages
61
Hi Guys, I have tried numerous times, but the below code only updates the first row from the excel sheet in Access. I want it to update the whole sheet in existing table in Access.

I don't want to create new entries but only update existing entries. and all entries in the excel are from the Access itself.

Code:
Sub UpdateCompletedEntries()
data_source = Sheets("Emails").range("B1").Value
cnn.Open ("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = '" & data_source & "'; JET OLEDB:Database Password=cadb@2015;")
Dim r As Long
i = 3
uid = Cells(i, 1).Value
Update = Cells(i, 6).Value
r = 3
Do While Len(range("A" & r).Formula) > 0
qry = "Update OPSC Set Live = " & Update & " Where Unique_ID = " & uid & ";"
rst.Open qry, cnn, adOpenKeyset, adLockOptimistic
i = i + 1
r = r + 1
Loop
cnn.Close
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,450
Messages
6,124,912
Members
449,195
Latest member
Stevenciu

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