Makhdoom Liaqat
New Member
- Joined
- Sep 22, 2022
- Messages
- 1
- Office Version
- 2013
- Platform
- Windows
Hi i am using the below query
but i want for all cells which meet the query
it will be with loop but i am not understanding how i use that loop
below is my code
Please help in it
but i want for all cells which meet the query
it will be with loop but i am not understanding how i use that loop
below is my code
VBA Code:
Sub UpdateTable()
Dim cnn As ADODB.Connection
Dim uSQL As String
Dim LR, LC As Long
Dim Group, Category As String
Dim itcode As Integer
' this is only for active cell i want for all cell in sheet which is on A column
Dim rngname As Range
Set rngname = ActiveCell
Set cnn = New Connection
itcode = ShCustomers.Cells(rngname.row, 1)
Group = "'" & ShCustomers.Cells(rngname.row, 2) & "'"
Category = "'" & ShCustomers.Cells(rngname.row, 3) & "'"
cnnstr = "Provider=SQLOLEDB; Data Source=MAK-SYS;Initial Catalog=db_bckupserver_test_sys;User ID=sa;Password=Rehman@123;Trusted_Connection=No"
cnn.Open cnnstr
uSQL = "UPDATE mak_items_chart SET [Group] = " & Group & " WHERE itcode = " & itcode
cnn.Execute uSQL
cnn.Close
Set cnn = Nothing
End Sub
Please help in it