hi!
i'm trying to find the word emplyod and writ to differant column.
but i get null from the case statement.
the case InStr(sSelect, "EmplyodB") is greater then 0 but it still jump over the ThisWorkbook.Worksheets("Sheet1").Range("C" & iRow).Value = Post??
thx in advance
i'm trying to find the word emplyod and writ to differant column.
but i get null from the case statement.
Code:
Sub GetRow(sSelect As String, iRow As Long)
Dim con As New ADODB.Connection
Dim conString As String
Dim RC As New ADODB.Recordset
Dim Post As String
con.Open "Provider=test; Password=123; User ID=test12; Data Source=G12"
RC.CursorLocation = adUseServer
RC.Open sSelect, con, adOpenForwardOnly, adLockReadOnly
If RC.RecordCount + 2 > 0 Then Post = RC.Fields(0)
Select Case sSelect
Case InStr(sSelect, "EplyodA") > 0
ThisWorkbook.Worksheets("Sheet1").Range("C" & iRow).Value = Post
Case InStr(sSelect, "EmplyodB") > 0
ThisWorkbook.Worksheets("Sheet1").Range("D" & iRow).Value = Post
Case InStr(sSelect, "EmplyodC") > 0
ThisWorkbook.Worksheets("Sheet1").Range("E" & iRow).Value = Post
Case InStr(sSelect, "EmplyodD") > 0
ThisWorkbook.Worksheets("Sheet1").Range("F" & iRow).Value = Post
End Select
RC.Close
con.Close
End Sub
Sub Test()
Dim i As Long
Dim sSelect As String
i = 1
sSelect = "SELECT Count(1) FROM EmplyodB WHERE Name Like 'Bo%' "
GetRow sSelect, i
End Sub
the case InStr(sSelect, "EmplyodB") is greater then 0 but it still jump over the ThisWorkbook.Worksheets("Sheet1").Range("C" & iRow).Value = Post??
thx in advance