Hi All,
I hope you can assist as need this working for tomorrow - The code below gets data from Worksheet $DataSheet however it shows up blank rows from the database and I can't seem to see why its doing this? :/
I hope you can assist as need this working for tomorrow - The code below gets data from Worksheet $DataSheet however it shows up blank rows from the database and I can't seem to see why its doing this? :/
VBA Code:
Sub sbADO()
Dim sSQLQry As String
Dim sSQLSting As String
Dim ReturnArray
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
DBPath = ThisWorkbook.FullName
sconnect = "Provider=jken.1;DSN=Excel Files;DBQ=" & DBPath & ";HDR=Yes';"
Conn.Open sconnect
sSQLSting = "Select [Column1], [Column2], [Column3], [Column4], [Column5], [Column6], [Column7], [Column8, [Column9], [Column10] from [DataSheet$] WHERE [Column1] in ('" & _
Join(Application.Transpose(Range("A2:A50").Value), "','") & "')"
mrs.Open sSQLSting, Conn
ActiveSheet.Range("A2").CopyFromRecordset mrs
mrs.Close
Conn.Close
Range("K2").Formula = "=IF($H2="""","""",$H2)"
Range("l2").Formula = "=TEXT(IF($G2<=$K2,$G2,$K2),""dd mmmm yyyy"")"
Range("M2").Formula = "=TEXT(IF($I2="""",""Currently Working"",$I2),""dd mmmm yyyy"")"
Range("N2").Formula = "=CONCATENATE($D2,"" "",$E2)"
Range("P2").Formula = "=TEXT(CONCATENATE(""Document"", "" For "", $D2, "" "", $E2),)"
Range("K2:K50").FillDown
Range("l2:L50").FillDown
Range("M2:M50").FillDown
Range("N2:N50").FillDown
Range("P2:P50").FillDown
End Sub