with code in which I import data from the web via a query then try to use end(xlUp).row to find the last row of the query. Right now, the code continues while the worksheet still displays "Getting Data...", so the last row always comes out as row 1. After the data is finished importing, however, the last row is most definitely not 1.
If I put a break point after the query and wait for the data to finish importing, then let the code finish, it runs perfectly. But how can I have the code automatically wait to move on until the data is finished importing?
I have some code I have created to set page breaks. Depending on a previous option, my report will be either 3,6,9,12, or 15 pages. The info on each page varies in length, but I use table headers to separate the data onto different pages so none of the tables are split into more than one page.
My problem when the code gets to a certain line, it gives me error 1004. I will hit "Debug", then I hit continue and the code finishes. I don't understand why I am getting an error on this line, and why I don't have to fix anything to get it to finish running.
i have a spread sheet which has a very complex simulaton in it. excel is not the ideal place for it, but it is not possible to port it wholesale to something more sensible. i have modified the code so that it is possible to run two copies of the spread sheet (in two seperate excel processes) at one time. Due to the dual core nature of the machine this has almost no overhead.
I have created a controlling spread sheet that is cabable of launching multiple copies of the simulation and starting the code executing. the problem is the controlling spread sheet always waits for the code to return before it continues, hence it would open two seperate versions of excel, start the first simulation executing and then wait until it completes before starting the next one. is there any way of starting a function in another work book without waiting for the execution to complete?
My current solution is to filter the Master Log so I only see Region 2, copy everything, then paste over Region 2, and repeat with 3, 4 and 5.
I have a master log (attached) that I import using Microsoft Query to 4 other spreadsheets (called Regional Logs), depending on the contents of the column "Region." I have all this figured out, but I can't figure out how to have the highlighting persist through the export and refresh. I don't think the attached file has any highlighting, but how I use this is I edit the Master Log throughout the week and highlight changes as I go. Coworkers use the 4 Regional Logs throughout the week to monitor different cases, particularly the new ones, so they need to see all changes for the week highlighted in yellow, which means the Regional Logs need to be linked to the Master Log and the highlighting must be visible any time a coworker opens the Regional Log. In addition, they are emailed across the state to county directors and they need to see the yellow-highlighted data, as well.
Currently, when exporting data using MS Query, no formatting persists. How can I ensure the highlighting persists? Or, is there another way to easily export the data, depending on the contents of the column "Region", which would allow the highlighting to persist
I have to import data into Excel from Access (yes, I have to import it to Excel and cannot use Access exclusively). When I import; however, the formatting does not come over correctly, most especially losing the formatting of numbers. I need one of two solutions:
1.) How to get the formatting to move over correctly?
2.) Or how I can save the formatting of a table, then be able to apply it as a "saved" format? The biggest thing is that the numbers will changed the number of decimal places and/or change from general numbers when I want to see them as currency.
The top table shows how i want this formatted, the bottom shows how it is importing.
I imported some data from an MDB file while working at home. created a macro to that effect. and it works fine at my home PC. but when i try t execute this macro on another PC or work place, then it gives error #13. i dont understand why. something is wrong with the code. i think it is the "WITH" code for query tables connection giving error ....
I have a workbook with a button that will run a macro to open files and import sheets based on if the user checked the box. Everything works perfectly EXCEPT for the importing of the sheets from newly opened workbook.
Here is what I want the code to do:
1. if the box is checked then open the file 2. Copy (import) the first sheet in the newly opened workbook and put it before the 1st sheet. 3. Close the workbook that the sheet was copied from and do not save changes 4. active the workbook that has the newly imported sheet.
And here is what i have thus far:
Code: Sub OpenFiles() Dim Folderpath As String Dim cell As Range Dim r, LRow As Single Dim Dbook As Workbook Set Dbook = ActiveWorkbook
[code]....
After stepping through it, the problem is here:
Code: Workbooks.Open Filename:=Folderpath & Range("B" & r).Value Source = Range("B" & r) Sheets(1).Copy Before:=Workbooks("CompletionWorksheet.xlsm").Sheets(1) 'How the hell do I close this ^ workbook ActiveWorkbook.Close savechanges:=False 'This closes the workbook where the sheet was copied to Windows("CompletionWorksheet.xlsm").Activate
one column has consecutive dates like this : 1/1/2008 2/1/2008 3/1/2008 4/1/2008 etc....
(the format is dd/mm/yyyy)
Now I have a function that retrieves data from the web for each date.
I want to use this function to look for specific data starting from 1/1/2008, and continue each day until the condition is met. then it should output the date where it was found first found.
The idea is to select an item i one cell, which in return will affect the following cells with the nutritional values. So far so good. I would then like, if a given amount is entered, it calculates the values.
A food item is typed in Cell A. The following cells will Index Match a table (on a different sheet), importing calculation formulas based on the food items nutritional value (Cells C - G). If an amount is typed in Cell B (i.e. 100 grams) the following cells will then calculate the correct nutritional values.
i learned to make an INDEX MATCH function, so that when i type "Gulerod" or something like that, the following cells import information from the Table tab... When the table contains fixed values, this works just fine. However - i tried to make the table (the cells) with calculation formulas (i.e. =SUM(4*B3))... this means the values in the tables are 0 untill a value is typed in B3 (in this example).
... however when i do the Index Match in my main tab, only the "0"'s are imported, and no matter what value i enter in B3 in the main tab, the following cells remains with the fixed value 0.
... so my question is - is it even possible to have the Index Match function import the calculation formula from the table and have it work in the main tab as well? Or is there any other way to make this work in Excel? Basically - to have the main sheet find the relevant data to use for calculation on a different tab/sheet, and then do the actually calculations on the main tab/sheet.
I have Created the below macro, however I cannot figure out how to make it loop so that is continues to copy the next column over ( so go from column E:E , To Column F:F, and then To Column G:G), and paste the data into the same column (D:D or Range paste_range) everytime, and print.
Sub paster_print() ' ' paster_print Macro ' ' Columns("E:E").Select Selection.Copy Application.Goto Reference:="paste_range" Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.Goto Reference:="Print_Area" Application.CutCopyMode = False End Sub
the title should read... pressing cancel in inputbox, continues the macro... In theory, pressing the cancel button should stop the macros, but it continues as if pressing ok button...
I am trying to import data from Yahoo, about half the time it works well, but the other half I get the Run-time error '1004' below.
Run-time error '1004': The file could not be accessed. Try on of the following: .. Make sure the specified folder exists. .. Make sure the folder that contains the file is not read-only. .. Make sure the file name does not contain any of the folloing charaters: < > ? [ ] : | or * .. Make sure the file/path name doesn't contain more than 218
I used a posted code to copy web query data from sheet2 to sheet1. Then a friend modified the code in order to Copy it to a new row in Sheet1 instead of a new column. The code works perfectly but I really wish that when the data is copied from Sheet2 to Sheet1 it will be only Values in order to keep my formulas and formats.
I read about .PasteSpecial xlPasteValues but I don't seem to find where exactly I should write it within the code.
I looking for a solution to change a Access Query Criteria using a VB code in Excel, without opening the Access DB and changing the criteria manualy?
My normal Job is it: 1) I Work all the time in Excel 2) At the end of the work in Excel, I need to open Access 3) Open a query (Called "MyQuery") 4) Change one parameter the Date: Between 01/10/2008 and 30/10/2008 (This for each month) 5) Run the query
I looking to get rid of points 2) to 5) by replacing with a Command button on an Excel sheet
Sub Change_Criteria_And_Run_Query()
Dim mydbase As Object Set mydbase = CreateObject("Access.Application") mydbase.OpenCurrentDatabase ("C:My doucmentsDB1.mdb")
mybase."MyQuery"."Date Criteria" = Between (Worksheet("Sheet1").Range("A1").value) and (Worksheet("Sheet1").Range("A2").value)
>>>>>The above line of code I have problems to get right!
I am currently working on a project that uses Excel to parse a .txt document. Its working quite well for me. It functions by having two worksheets. In the first worksheet I use the " import external data" menu to import my .txt file. In another worksheet I have set up fields that show only the important information from the .txt file and leave the junk behind.
I’m looking to improve the functionality of this by adding a button to automatically clear the data in the first worksheet so that new data can be added quickly.
I have searched the forum and found a couple of threads on "QueryTables". After reading up on those, I have made a simple button with the following code.
After I load a .txt file and parse it using the formulas set up, I copy my needed information and then press this button. The cells clear, and the QueryTables are "reset" (maybe not the right word). Now a different .txt file can be imported and the process starts again.
The problem I am having is that. If there is no "QueryTables.Item(1)" to delete, I get a run time error. (Run-time error '9': Subscript out of range).
Would anyone know how to make my button conditional to having a "QueryTable" active? I.E. If I press it when there is no data loaded it doesn't do anything or give me that error.
I have recorded the following marco and it works fine. I would like to modify it so the user would highlight a range of cells rather than have the fixed area :
I have an MS Access query that contains a parameter. The parameter is a date field, and I have configured that in the Access query. If I run the query within the MS Access user interface, it prompts me for the paramater value as expected, and runs just fine. However, I want to connect to this query from within Excel as a data source.
I have created a connection to the Access file using ODBC from within Excel. In the MS Query window, I am merely selecting all of the fields resident in the MS Access query, and returning all values. In other words, there is no selection criteria in the MS Query. I have done this many times with Access queries that DO NOT contain a parameter, and everything works fine. However, in this instance, I need to pass a parameter through to MS Access in order for the query to run. At the moment, I get the "Too Few Paramaters...1 expected" error message. This makes sense, because I haven't figured out how to pass the paramater to MS Access.
Is there a way to structure this that does not involve VB code? If so, I'd love to know how. I have tried creating parameters in MS-Query with the same name, but although I get the prompt it doesn't connect with the Access query as the source for the parameter value.
If the solution requires using code, I'm good with VB Code in Excel...is there VB for Excel code that could make this happen?
Failing that, I guess there must be (I've seen a few in my search thus far) Access VB Code that can make this work. I'm very rusty using VB with Access, so this is my least favored solution. However, if this is the only option, keep in mind that I need to pass the paramater ultimately from a user who will initiate the process using Excel.
Need the query parameters which takes the date from the cell into the query. How should I modify my query if it needs to take the date from a cell?? The bold one date should be picked from one of the cell in sheet 2.
My query is this WEB 1 http://fc-web-phl1-101.phl1:8090/gp/...runReport.y=12
I have a csv file on another drive on the network that i need to query. I believe that ms query would be the best way. I know that a DSN needs to be setup but this macro will be used by various users who wont know how to do that. thus I would like to create one via VBA every time the task needs to be run. I haven't a clue how to do this and i need it to be explained to me in general terms with words of one syllable!
A web query I am trying to use to bring an online data table into my worksheet is broken. Now, instead of returning the data table nicely into my worksheet, it imports the code of the webpage, instead, and turns my worksheet into a mess.
The query used to work but there was recently an "upgrade" to the program that populates the web table and the query no longer works and just returns the code for the page, instead. I can see the html code for the table in all of the code it returns but I really need the table to import cleanly into excel.
I can't talk to the people who changed the web program.
I'm using the code below to lock certain cells depending on the value of other cells. The code below deals with one line of my spreadsheet only and as the spreadsheet comprises 38 data entry rows I've repeated this code 38 times in the worksheet module with the appropriate changes to row numbers.
It works, but causes much screen flickering and "thinking". I'm new to vba so no doubt I've made this code too extensive or lengthy or whatever (or just plain wrong).
Can anyone assist with suggestions on how to simplify the code and/or help with code to handle all 38 lines without repeating the routine 38 times?
I'm trying to query a query in Access 2003, from Excel 2003.
The query in Access looks like: AccessQuery: [SELECT VBAFunction(field1) FROM Table]
The query in Excel looks like: ExcelQuery: [SELECT * FROM AccessQuery]
I use the following VBA code in Excel to excecute the query:
With ThisWorkbook.Worksheets(cDataSheetName).QueryTables.Add(Connection:=strConnection, _ Destination:=ThisWorkbook.Worksheets(cDataSheetName).Range("A1"), Sql:=strQuery) .RowNumbers = True .Refresh BackgroundQuery:=False iResultRowCount = .ResultRange.Rows.Count End With When I execute this code I get the error message 'SQL Syntax Error' (Error 1004). When I remove the VBA function from the query in Access, it all works fine.
I created an Ms Excel Database Query to bring in data from MS Access. (versions 2002 of MS Excel and Ms Access). The query works fine initially. I can right click, choose Edit Query and change my criteria. Results are returned almost instantly.
My problem is that, once I save the workbook, or autosave happens, I get an error when I right-click to Edit Query: This query cannot be edited by the Query Wizard..
Is it possible to set parameters on a query but use a wildcard to return all instances? I have a query that I want to be able to set multiple parameters on but give the user the ability to select as many or as few parameters as they want to see. 2 of the parameters are number fields and 2 are text fields with no spaces.
So my problem is that i have a table that is imported from sql and everyday i manually type in comments in a column that i made in excel next to the table that is imported. evreytime i refresh the data and get new data the comments are gone, how do i keep the comments with the row that i type it in?
I am importing data from a csv file into another program. For some reason this particular cell is causing everything past it in the same row to be thrown off. It is moving bits and pieces to the next column, then the next, etc....all in the same row though.
Can you see anything in this data that would cause issues in a csv file when importing. The data in this cell is html code for an ecommerce item description.
i have a script to import a workbook which works fine, but when the data is imported i would like to have all the data in the cells aligned to the left of the cells, as im new to vba i can work this out.
Below is the script i'm using to import.
I would like this to aligned all cells to the left and centered when imported.
Sub tst() With workbooks.open("C:example.xls") with .sheets(1).usedrange thisworkbook.sheets(1).cells(rows.count,1).end(xlup).offset(1).resize(.rows.count,columns.count)=.value end with .close False End with End Sub
I am trying to import from Excel Worksheet 1 into Excel Worksheet 2 in a user-friendly manner. I've created a form in Excel Worksheet 2 that allows the user to browse for a file and select it.
All I want to do is copy columns A through I from Worksheet 1 into Worksheet 2. How can I do this very smoothly without needing to open up Worksheet 1?
How can I limit the number of lines when importing a file? Limit the import to the first 53 lines of a file that has 50,000+ lines.
Want to import the first "XX" set of lines, then I want to skip a set of lines, then continue to import the rest of the lines. The second import needs to be inserted 2 or 3 lines down from the first import.
There is the function:
Workbooks.OpenText Filename:=
But it only has a StartRow and can not specify the "EndRow". Also can not specify where to start in the worksheet, i.e. Cell A5