When the test runs it uses a template to fill out the information then it saves as a .xls file. I open this file to write data to customer spreadsheet. The macro I am writing is being tied to the template so that when the new file is created the send data button tied to the macro will open C:\ , then I choose the customers file and the macro checks for an empty cell in R17 Starting at CG. Then the data is
copied from the Test documents into the file. After I added the set ws=ActiveSheet I got a runtime error '424' object required. I am assuming that I am missing a reference. Following is my code. I have commented out some of my code at the bottom.
Dim ws As Worksheet
Dim strFN As String
Sub SendData()
'
' SendData Macro
' Macro recorded 10/9/2013 by msmith
'
' The following opens a file of your choice
Set ws = ActiveWorksheet
strFN = Application.GetOpenFilename
If strFN = "False" Then
Exit Sub
Else: Workbooks.Open Filename:=strFN
MsgBox strFN
End If
Range("G17").Activate
Do Until IsEmpty(ActiveCell.Value)
ActiveCell.Offset(0, 1).Activate
Loop
ActiveCell.Offset(0, 0) = ws.Cells("4, 2")
ActiveCell.Offset(2, 0) = ws.Cells("6, 2")
ActiveCell.Offset(1, 0) = ws.Cells("7, 2")
ActiveCell.Offset(1, 0) = ws.Cells("8, 2")
ActiveCell.Offset(1, 0) = ws.Cells("9, 2")
ActiveCell.Offset(1, 0) = ws.Cells("11, 2")
ActiveCell.Offset(1, 0) = ws.Cells("12, 2")
ActiveCell.Offset(1, 0) = ws.Cells("13, 2")
ActiveCell.Offset(1, 0) = ws.Cells("14, 2")
'Workbooks.Open Filename:=strFN
'ActiveCell.Offset(0, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!R4C2"
'ActiveCell.Offset(2, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(1, 0).Range("A1").Select
'ActiveCell.FormulaR1C1 = "='C:\Test_Results\MASTER10142013.xls'!RC+1"
'ActiveCell.Offset(-9, 1).Range("A1").Select
End Sub
I have been busy with other projects and am just now looking at this program. Thank you for your assistance and kindness. I just received the book 'EXCEL 2003 Power Programming with VBA' by John Walkenback. I hope this will help me to have a better understanding.
Bookmarks