Error using TransferSpreadsheet to import an Excel spreadsheet - excel

I have a routine that helps me locate a the row of word in a standardized worksheet.
Based on the location of the word - for example, I search in column 'A'
It finds the word on row 7.
I now know that I can use the range A8:M14 as the data I want to import into my table, so I created a function 'GETBASELINE' that would just return that string - "A8:M14"
So now I have a table called tbl_TEMP_Import with these fields
BASELINE|OCT|NOV|DEC|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP
I call it like so:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tbl_TEMP_Import", strPath, False, GetBASELINE(strPath, strSheet)
I get Error 2391 Field 'F1' doesn't exist in destination tbl_TEMP_Import
If I change it to 'True' for 'has field names'
I get Error 3270 'Property Not Found'
I wish I could get better debugging. Doesn't seem too complex to accomplish this.

Answer with 'True' for 'has field names':
You have to give the table the field heading as well... so the code for GETBASELINE must equal "A7:M8" ... (I'm not sure where 14 came from)
A7:M7 are Field names
A8:M8 are 1st set of values
Answer with 'False' for 'has Field names':
You must change the field names, because the call brings in temp field names, F1,F2 and so on
Manually you can change the names. It is programmable as well.
In any event, once you call the script one way, be careful not to 'mix' them with each other! Delete one before you call the next

Related

2 nest if with different source data excel

I have 2 data sources and i want to lookup data using Vlookup by using unique ID,
1st data source will show "X" if the ID locate there,
2nd data source will show "Y" if the ID locate there,
the other responses of ID lookup will show nothing ""
Data source 1:
20000543
10056577
10032255
10008287
10011657
10008119
10008212
10007880
10052842
10007959
10062445
10011361
10008079
10008836
10007792
10052651
10007793
10047404
10007913
10007528
10008252
10007388
10007311
10057445
10036263
20004767
20004010
20001276
20010704
10039655
10062427
20010703
10048331
Data source 2:
20003695
20010673
10011463
10021645
10007439
20001123
10008276
10055885
10007718
10007587
10007364
10055257
10007651
10056216
10054797
10052500
10059984
10027674
10010153
10007808
10008182
10007763
10007428
10008102
10050130
10037579
10021909
10009539
10057979
I want to lookup value by using ID "10008102" which is locate in Data source 2 than it will show "Y" for final result,
How can I achieve this?
Much appreciate that.
Thank you
Please don't kill me for the overkill, but I came up with this:
=IF(IFNA(MATCH(A1,Sheet2!A$1:A$29,0),"N")="N","N","Y")
The story:
Match(...,...,0) searches for an exact match (hence the zero).
you need to look for a relative reference, like A1 (without dollarsigns), so that you can drag down and use another cell reference at any time
you need to look inside a fix array, like A$1:A$29, so that, when you drag down, you don't modify the array you're looking in.
Match() either gives a number or an #N/A error in case not found.
IFNA() translates #N/A to "N" (but there's no else-case in IFNA())
IF() has an else-case.
I'm inviting Excel wizards to come up with a simpler solution :-)
Do you possibly want to account for the value existing in both or none of the columns?
=IF(AND(COUNTIF(A:A,E2)>0,COUNTIF(B:B;E2)>0),"X&Y",
IF(COUNTIF(A:A,E2)>0,"X",
IF(COUNTIF(B:B,E2)>0,"Y",
"NONE")))

OR Formula in Word document not returning a value

I am working on a document where I need to be able to test multiple options in an if statement to see if one of them are true to decide if a paragraph displays on the document. I have been trying to figure out why my OR formula is not returning a value for me to test and I am not sure why it is not showing anything when it is updating.
I have inserted a field and added a formula within that field that I am hoping will work with my If statement to show the proper paragraph contens.
When I use an Or statement, even one as simple as { OR(1=1) } and update and toggle the field I get no result. From what I have read I should get a 1 or a 0, but I don't seem to get either of these results. The line just ends up blank. When I test it with my If formula it always shows the false result, even when the Or contains a true result.
The formula I am currently working with is:
{ IF{ OR("$event.eventType.name}" = "Birthday", "$event.eventType.name}" =
"Conference" } "Yes" "No" }
If I update and toggle the Or field it shows blank, no result either true or false, and makes the If formula show as false event on results where it should show true. As I mentioned above I even tried setting it to 1=1 and still could not get it to show as true. Not sure if there is something I am missing in working with the formula.
Any suggestions would be appreciated.
It's not clear from your post what $event.eventType.name is. Presumably it's a field generated by an Addin. In that case, you should be able to use something like:
{IF{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0}# 0}> 0 "Yes" "No"}
or:
{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0} \# "'Yes',,'No'"}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. If your fields are a kind of mergefield, you'll need to insert 'MERGEFIELD ' at the start of each one, thus:
{MERGEFIELD $event.eventType.name}

fetch html data from website into excel vba

Object does not support this property or method.
Error occur on this line:
For Each ele In objIE.document.getElementsByClassName("table info-table").getElementsByTagName("tr")
getElementsByClassName() returns a collection of matching elements (even if there's only one match), so you need something like (e.g.):
For Each ele In objIE.document.getElementsByClassName( _
"table info-table")(0).getElementsByTagName("tr")
which will loop over the tr elements in the first table with a matching class name.
If you need a different table you'll need to adjust the (0)

No value given for one or more required parameters - OLEDB cmd updating Excel

I am getting the error in the title when trying to update a row in Excel with blank values in these positions [BI6:DP6].
I have counted and it appears there are 60 spots in these cells to update, so I am stuck.
Any ideas? String to update is below:
UPDATE [My Sheet$BI6:DP6] SET F1=1, F2=0, F3=0, F4=0, F5=0, F6=1, F7=0, F8=1, F9=1, F10=1, F11=1, F12=1, F13=0, F14=0, F15=1, F16=1, F17=1, F18=1, F19=1, F20=1, F21=1, F22=0, F23=0, F24=0, F25=0, F26=0, F27=0, F28=1, F29=1, F30=0, F31=0, F32=0, F33=1, F34=0, F35=1, F36=1, F37=1, F38=1, F39=0, F40=0, F41=0, F42=1, F43=1, F44=0, F45=1, F46=0, F47=0, F48=1, F49=0, F50=0, F51=0, F52=1, F53=1, F54=0, F55=1, F56=0, F57=0, F58=1, F59=0, F60=0
I was using an update statement for a macro enabled spreadsheet, which required us to use the 'HDR=NO' value for Extended Properties attribute of the spreadsheet. Along with that, every cell in the spreadsheet needed to be formatted to "Text" instead of "General" (or numeric, currency) in this case in order to get the values into the cells correctly.
Excel apparently attempts to covert these values with little to no information returning back upon error in the OLEDB connection, and so it makes this issue very difficult to fix.

Importing data from Excel into Access using DAO and WHERE clause

I need to import certain information from an Excel file into an Access DB and in order to do this, I am using DAO.
The user gets the excel source file from a system, he does not need to directly interact with it. This source file has 10 columns and I would need to retrieve only certain records from it.
I am using this to retrieve all the records:
Set destinationFile = CurrentDb
Set dbtmp = OpenDatabase(sourceFile, False, True, "Excel 8.0;")
DoEvents
Set rs = dbtmp.OpenRecordset("SELECT * FROM [EEX_Avail_Cap_ALL_DEU_D1_S_Y1$A1:J65536]")
My problem comes when I want to retrieve only certain records using a WHERE clause. The name of the field where I want to apply the clause is 'Date (UCT)' (remember that the user gets this source file from another system) and I can not get the WHERE clause to work on it. If I apply the WHERE clause on another field, whose name does not have ( ) or spaces, then it works. Example:
Set rs = dbtmp.OpenRecordset("SELECT * FROM [EEX_Avail_Cap_ALL_DEU_D1_S_Y1$A1:J65536] WHERE Other = 12925")
The previous instruction will retrieve only the number of records where the field Other has the value 12925.
Could anyone please tell me how can I achieve the same result but with a field name that has spaces and parenthesis i.e. 'Date (UCT)' ?
Thank you very much.
Octavio
Try enclosing the field name in square brackets:
SELECT * FROM [EEX_Avail_Cap_ALL_DEU_D1_S_Y1$A1:J65536] WHERE [Date (UCT)] = 12925
or if it's a date we are looking for:
SELECT * FROM [EEX_Avail_Cap_ALL_DEU_D1_S_Y1$A1:J65536] WHERE [Date (UCT)] = #02/14/13#;
To use date literal you must enclose it in # characters and write the date in MM/DD/YY format regardless of any regional settings on your machine

Resources