Been using Excel for a few versions, but this is my first try at VBA.
I have no idea if this is the best method to do what I want. I am just trying different things, in hopes of finding one that works well.
I have a template 'invoice', from which I create all my invoices. I want to take certain data from those invoices and put it in a database, to be used in a quarterly fashion.
Prior to this I had been using the template wizard with data tracking, but it no longer works well in Excel 2010.Doing some googling I came across a few videos on how to transfer data from workbooks/worksheets to workbooks/worksheets using VBA.I followed the code in one of the videos and tried to adapt it for my own uses.
I am not allowed to provide link at this time.
I enter the data on the template invoice [Service Invoice] [It uses a CommandButton, on the invoice template, which one clicks on to transfer the data].
It opens the database worksheet [TRACKING] and then the following error occurs.
"runtime error 438. Object doesn't support this property or method."
It gives me the opportunity to DEBUG, but when I try to debug, I get the above error at the line - "Worksheets("Tracking").Range ("a1")".
I have googled the error but, cannot understand the various solutions given, mainly because I see no clear explanation of what "runtime error 438" means,so therefore do not know what to look for in solving the problem.
What could be the problem? Does it not like the range? The worksheet has a row of titles [a1 to o1] . I have tried removing them, thinking it would create it's own titles, but it changed nothing.This is my code:
Private Sub CommandButton1_Click() Dim INVOICE As Single Dim DATEs As Date Dim TOTAL As Currency Dim GNGInvDBase As Workbook Worksheets("Service Invoice").Select INVOICE = Range("D6") Worksheets("Service Invoice").Select DATEs = Range("D4") Worksheets("Service Invoice").Select TOTAL = Range("D41") Set GNGInvDBase = Workbooks.Open("G:\GNGRen\GNGInvDBase.xlsx") Worksheets("Tracking").Select Worksheets("Tracking").Range ("a1") RowCount = Worksheets("Tracking").Range("a1").CurrentRegion.Rows.Count With Worksheets("Tracking").Range("a1") .Offset(RowCount, 1) = INVOICE .Offset(RowCount, 2) = DATEs .Offset(RowCount, 3) = TOTAL End With GNGInvDBase.Save End Sub