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. :confused:
Cheers
-Rob
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:
Dim lLastRow as Long
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).
Re: Transfer Data to Customer Database
You can also use the SpecialCells function.
VB Code:
ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Column