+ Reply to Thread
Results 1 to 5 of 5

Conditional Statement In VBA

  1. #1
    Registered User
    Join Date
    01-18-2012
    Location
    Los Angeles USA
    MS-Off Ver
    Excel Office 365
    Posts
    80

    Conditional Statement In VBA

    I have this code to send an invoice, the invoice having a header and multiple invoice lines, to a database worksheet. In this example I would send four invoice lines along the header information to the database. Each of the four lines would have common header information. How would I stop the posting of lines three and four if they were blank? Other wise I would create two extra records in the database that had only the header information, Invoice no, Customer name etc., which I don't want. [c23], [d23], [f23], [b23] and [c24], [d24], [f24, [b24] would be blank. I assume I would need some sort of if statement in VBA, what would this If statement look like in VBA?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Conditional Statement In VBA

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 03-17-2012 at 02:37 AM.

  3. #3
    Registered User
    Join Date
    01-18-2012
    Location
    Los Angeles USA
    MS-Off Ver
    Excel Office 365
    Posts
    80

    Re: Conditional Statement In VBA

    Thanks very much for your help, if I had additional lines I assume I would just include the corresponding number of If statements?

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Conditional Statement In VBA

    Please Login or Register  to view this content.
    Last edited by snb; 03-18-2012 at 03:40 PM.



  5. #5
    Registered User
    Join Date
    01-18-2012
    Location
    Los Angeles USA
    MS-Off Ver
    Excel Office 365
    Posts
    80

    Re: Conditional Statement In VBA

    I ended up with the code below, which seems to work okay. Thanks for the help. Now to the details.

    1. The database is a table, how do I maintain the table as a table, if I post records to the bottom of the table with the shown code, it has some manually added records, those records no longer take on the properties of the table? Is there a way to force the table to remain a table after I post a record to it?

    2. Secondly, how would I skip cells in the record, there are cells in the table that have vlookups and formulas in them that I would like to apply to the posted record. So I would like to post nothing in a column so I can use the table's formulas, then post the next form cell in the next database column.

    3. How would I tell Excel which column to start entering the data from the form? Right now I'm sending a cell that is blank that goes into the first column. The first column is blank because I'm using Freeze First Column. The actual new record data starts at column 2.

    4. Resize(1,13) Does the the 1 here determine how many copies to make of data?

    Please Login or Register  to view this content.
    Last edited by laguna92651; 03-21-2012 at 01:53 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1