Forum Discussion
Excel Code trying to copy cell data from one sheet to another based on 2 criteria
Hi - Sorry for the delay - I was away.
I fixed the error however these 2 rows seem to be the problem. The values remain empty, hence when the update happens it fills with nothing.
baselineDate = wsPlan.Cells(i, "I").Value
percentComplete = wsPlan.Cells(i, "L").Value
I have no windows PC to debug fully EXCEL vba api.BUT I have found there are sapces after Test like "Test " in table Track.
x="ADODB.Connection"
Set Conn = CreateObject(x)
Conn.Open "Provider=Microsoft.Ace.OLEDB.12.0;Extended Properties='Excel 12.0;';Data Source=" & ThisWorkbook.FullName
sql="select "
sql=sql & " * from [Tracker$]"
sql= sql & " where f6 like ""Test%"""
'olny add % wildcard to match "Test "
set Rst=Conn.Execute(sql)
ActiveCell.CopyFromRecordset Rst
sql="select "
sql=sql & " * from [My Plan$]"
set Rst=Conn.Execute(sql)
ActiveCell.CopyFromRecordset Rst
- PaulD0925Sep 26, 2025Copper Contributor
It works.
I was making a silly mistake. I had copied the Sub twice. I wanted the original and then a version with any modifications. Hence I was working on one version but running the other.
Sorry for messing you around.
This is excellent code and really really helps me - many thx.
- peiyezhuSep 26, 2025Bronze Contributor
Additionly,I guess you can upload workbooks to this forum instead of 1 driver.