Results 1 to 3 of 3

Thread: Transfer Data to Customer Database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Transfer Data to Customer Database

    I'm trying to make a customer database where the user inputs some details (ID, name, address etc) and then clicks a button and the data is transferred to another table. Hopefully the diagram below will give an idea what I mean:

    http://www.sudsolutions.com/stuff/Excel_Table.JPG

    But how do I get Excel to add the new customer details to the next available empty slot?

    I can get it to do it in a very basic way but it always has to select the cells and for reasons I won't go into here it must do it without having to actually select the cells in question.

    I'm sure there's an easy VBA macro that could do this but I'm stumped.

    Cheers
    -Rob
    http://www.sudsolutions.com

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Transfer Data to Customer Database

    You can get the last used row (in this case ID=3) by using code like this:
    VB Code:
    1. Dim lLastRow as Long
    2.   lLastRow = [i]WorksheetObject[/i].UsedRange.Rows.Count
    .. you can then add 1 to this to get the row to insert on.

    Alternatively you can use a loop to find the first blank cell in column A (which would cause problems if you had any blank entries).

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Transfer Data to Customer Database

    You can also use the SpecialCells function.
    VB Code:
    1. ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
    2. ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width