View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Ben McClave Ben McClave is offline
external usenet poster
 
Posts: 173
Default Macro to choose data and export in another workbook

Jerry,

Is it the same error, or a different one? If you are trying it in a workbook that has not been saved, then you may get an error on the line:

cn.Open strCon

If so, try saving the workbook and running it again. If that is not the issue, you may also want to double-check any Range references in the code. For example, the sSQL parameter assumes that the relevant column header on the "ICD" sheet is in cell A1. If this is incorrect, the SQL query will break.