Posts by cytop

    Re: VBA Recordset.Open Error


    You don't give details of the actual SQL statement, but that error is usually raised when trying to append data into a table (as in database table) but the data for one, or more, of the fields is longer than the defined length of the field - and I am aware your thread title says 'Open Error'...

    Re: Help with if or loop


    OK, so if you search for 1, you want to remove 2 & 3. If you search for 3, you want to remove 1 & 2.


    I'm assuming these are place markers so that raises the question of what you want to do here. Just replace the text leaving the paragraph markers intact or remove the entire paragraph so extra (now) blank lines are removed?


    If so, it seems simplest to just have 1 place marker and simply replace that with the contents of whatever cell is being used for the source text.

    Re: Help with if or loop


    Quote

    But what i want is that the text that is linked with number 2 and remove the other texts


    I'm sorry - I really don't understand...


    Can you explain what is to happen in words?


    For example, if A3 = 2, the current code:

    • Searches for '<<OPTIONEEL2>>'. If found replaces with the text in C5
    • Searches for '<<A2>>'. If found replaces with the text in D3
    • Searches for '<<A3>>'. If found replaces with the text in D4

    Re: Help with if or loop


    Quote

    I have created a code that can realise this


    Then post your code, I would like to see what you have done with the following lines:

    Code
    1. If Range("A3") = 2 Then
    2. End If


    Plus, it might help to explain what you are asking now...


    If you post code then please use 'Code Tags'. These format and indent code making it easier to read. Your first post was edited by me but your turn now. To add code tags type '[noparse]

    Code
    1. [/noparse][/b]' before the code and '[b][noparse]

    [/noparse][/b]' after.

    Re: Code does not 'run' when assigned to a button


    Starting at the simplest... The Error 6 is a result of an invalid assignment to a particular data type. It is such a fundamental concept in any programming language that you need to understand it yourself to avoid it in future. You could start by reading this (That page is from an Access book but the concept is the same for Excel - it's all VBA).


    The remaining issues are not program errors as such but logic errors - it is not doing as you expect. The only pointer I can give here is that there are some references to ranges that are not qualified with a sheet name - it is possible the incorrect sheet is being updated.


    Without a copy of the workbook I can't be any more exact, a quick read of the code doesn't show any glaring issues, so this is one for you to try debugging.


    Debugging is an essential part of any development, you can step through the code line by line testing the values of variables before a line executes to confirm it is working with the right values, you can change the value stored in a variable or even change which like will execute next (within limits). For a good basic primer on debugging, see this page.

    Re: VBA to Retrieve data from Access database based on formula


    How you expect anyone to answer this when you give absolutely no information about the formula or database is beyond me.


    This thread is locked. Feel free to start another thread explaining your problem fully in the first post. After fully explaining everything about the formula and the database (location, structure, user ID and password if needed - not forgetting the exact parameters for the SQL statement) please include the following,edited, statements from your initial message.


    Quote

    1.I want someone else to create custom formula in excel using VBA.
    2. Based on that formula I want someone else to retrieve data from Access.

    Re: If a cell meets a condition, copy that row to another worksheet


    Please do not post questions in threads started by other members.


    If you have a query then start your own thread, give it an accurate and concise title that summarises your problem and explain your issue fully.


    If your question relates to this (or any other) thread, then include a link by copying the URL from the address bar of your browser and pasting into your message.


    Make sure you explain exactly the changes needed and how you would see them working. The code in this thread relates to selections from a combobox but you "dont want to use combo box" - please explain the process you have in mind.

    Re: Track new data


    I'm sorry, there's still not enough information.


    Quote

    the above table updated automatically from another sheet


    How? Formula? VBA code?


    As mentioned in my previous post

    Quote

    it is essential that the structure of the actual workbook is retained.


    Quote

    If a cell contains a formula keep the formula in the sample


    You need a representative sample workbook plus any additional data/workbooks to supply the source data.

    Re: Equal or less then, does not work when passing a date to SQL via vba for Teradata


    OK - I can't really help as I don't use Teradata, and never had. Was just going on the comments in your post.


    One final thing, rather than the " marks (Chr(34)), try single quotes - but it's more likely you'll have to CAST the string to a Date type for the DBMS to recognise it. Hopefully someone familiar with Teradata will happen along...


    Code
    1. ...AND ((MVT_DATE) <= '" & ToDate & "') Order By...


    (Note single quote before and after "s)

    Re: Equal or less then, does not work when passing a date to SQL via vba for Teradata


    Assuming that the BRANCH_NO & ACCOUNT_NO fields are truly numeric and that "dates are entered in Teradata SQL as text" and that the variable ToDate has been populated with a date in the correct format (lots of assumptions), then the following may work:


    Code
    1. ...AND ((MVT_DATE) <= " & Chr(34) & ToDate & Chr(34) & ") Order By...