santhoshbes
Board Regular
- Joined
- Sep 29, 2009
- Messages
- 69
Hi All,
Need your help in Macro to update the existing list entries in share point. I have a macro to upload new entries in share point. Need guidance to edit the existing entries.
Macro to add new entries:
Sub ABM()
Application.ScreenUpdating = False
'Dim g As String
'f = InputBox("Enter your Username(NTLOGIN)")
'Sheet3.Cells(2, 5).Value = f
'g = Sheet1.Cells(4, 5).Value
'Dim z As String
a = MsgBox("Are you sure, you need to upload the data", vbYesNo, "ABM_TT")
'MsgBox g
If a = vbYes Then
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open " Provider = Microsoft.Ace.oledb.12.0;Data source= C:\Users\kumaarsa\Desktop\Automated Files\ABM_TT.accdb"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "ABM_TT", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
r = 3 ' the start row in the worksheet
Sheets("ABM_TT").Select
n = Sheet1.Range("B1:B100000").SpecialCells(xlCellTypeConstants).Count
'MsgBox n
y = n
For i = 2 To n
'Do While Range("A1").Value > 0
'rng = Sheets("Input").UsedRange
'MsgBox a
' repeat until first empty cell in column A
'a = Date
With rs
.AddNew ' create a new record
' add values to each field in the record
'.Fields("Date") = Sheet1.Cells(i, 1).Value
'.Fields("Title") = "Roles and Responsibilities Tracker"
.Fields("Week Ending") = Sheet1.Cells(i, 1).Value
.Fields("ABM Function or Group") = Sheet1.Cells(i, 2).Value
.Fields("SRM Activities") = Sheet1.Cells(i, 3).Value
.Fields("Other Activities") = Sheet1.Cells(i, 4).Value
.Fields("Description") = Sheet1.Cells(i, 5).Value
.Fields("Hours per Week") = Sheet1.Cells(i, 6).Value
'.Fields("AvailableTime") = Sheet1.Cells(i, 5).Value
'.Fields("UtilizationPercentage") = Sheet1.Cells(i, 9).Value
.Update ' stores the new record
End With
Next i
'r = r + 1 ' next row
rs.Close
Set rs = Nothing
MsgBox "Data Uploaded in Sharepoint", vbInformation, "Result"
Else
MsgBox "Alter the entries and Try again", vbCritical, "ABM_TT"
End If
End Sub
Need your help in Macro to update the existing list entries in share point. I have a macro to upload new entries in share point. Need guidance to edit the existing entries.
Macro to add new entries:
Sub ABM()
Application.ScreenUpdating = False
'Dim g As String
'f = InputBox("Enter your Username(NTLOGIN)")
'Sheet3.Cells(2, 5).Value = f
'g = Sheet1.Cells(4, 5).Value
'Dim z As String
a = MsgBox("Are you sure, you need to upload the data", vbYesNo, "ABM_TT")
'MsgBox g
If a = vbYes Then
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open " Provider = Microsoft.Ace.oledb.12.0;Data source= C:\Users\kumaarsa\Desktop\Automated Files\ABM_TT.accdb"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "ABM_TT", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
r = 3 ' the start row in the worksheet
Sheets("ABM_TT").Select
n = Sheet1.Range("B1:B100000").SpecialCells(xlCellTypeConstants).Count
'MsgBox n
y = n
For i = 2 To n
'Do While Range("A1").Value > 0
'rng = Sheets("Input").UsedRange
'MsgBox a
' repeat until first empty cell in column A
'a = Date
With rs
.AddNew ' create a new record
' add values to each field in the record
'.Fields("Date") = Sheet1.Cells(i, 1).Value
'.Fields("Title") = "Roles and Responsibilities Tracker"
.Fields("Week Ending") = Sheet1.Cells(i, 1).Value
.Fields("ABM Function or Group") = Sheet1.Cells(i, 2).Value
.Fields("SRM Activities") = Sheet1.Cells(i, 3).Value
.Fields("Other Activities") = Sheet1.Cells(i, 4).Value
.Fields("Description") = Sheet1.Cells(i, 5).Value
.Fields("Hours per Week") = Sheet1.Cells(i, 6).Value
'.Fields("AvailableTime") = Sheet1.Cells(i, 5).Value
'.Fields("UtilizationPercentage") = Sheet1.Cells(i, 9).Value
.Update ' stores the new record
End With
Next i
'r = r + 1 ' next row
rs.Close
Set rs = Nothing
MsgBox "Data Uploaded in Sharepoint", vbInformation, "Result"
Else
MsgBox "Alter the entries and Try again", vbCritical, "ABM_TT"
End If
End Sub