Skip to content
Advertisement

Tag: vba

SQL in Excel: Cannot call declared variable

I am trying to breakdown my SQL string in Excel VBA, storing my variables in the first part of the SQL, and calling them in the second part. It seems that declared variables is not my friend here? First part(Declaring my variable) Second part(Calling my variable) Using a temp table works: But calling the variable doesn’t: Answer In-memory @variables are

SQL Query with Excel VBA

I’m trying to run a SQL query with Excel VBA. I got the query from someone else. When I run this query, I’m getting the following error message: “The SELECT statement includes a reserve word or an argument name that is misspelled or missing, or the punctuation is incorrect.” I can’t figure out what is wrong (plus I’ve never tried

Using the Like operator with two fields

How do I use the Like operator to join two unidentical tables as below? My main problem is on how to compare the PO filed on tbl2 to the EditNo on tbl1 field. Please see sample tables and expected results below: tbl1: tbl2: Expected: Query: SELECT * FROM tbl2 INNER JOIN tbl1 ON tbl2.PONo LIKE EditNo.PO; Answer You need wildcards:

How do I write my SQL Code in MS Access SQL?

Table Name: Records ID Date Time Status BoxType Material Rack EmployeeNr Transaction 1 25-05-2020 13:11:12 70 36757 4 4 188 2 2 25-05-2020 13:12:40 71 31178 2 5 188 2 3 25-05-2020 13:13:31 71 31178 2 5 188 102 4 27-05-2020 13:14:14 71 38444 3 2 181 3 5 27-05-2020 13:14:15 71 38444 3 2 181 3 6 27-05-2020 13:14:41

How to change SQL queries in Excel using VBA?

I have a workbook connected to a database that has stock data. I have around 500 stock symbol data and I fetch them one by one by entering the stock symbol (pink highlighted) in the query as shown below. All the time I have to open Connection Properties then Definition to change the stock symbol. This process is time-consuming. I

Multiple columns from one column

I track the aging of customer invoices. The below code example returns the balance of customer invoices by customer that are between 0 and 30 days old. However, I want to run one query that pulls separate columns into Excel for each customer’s balance aged between 0 and 30 days, 31 and 60, 61 and 90, and finally over 90

Advertisement