Hello: I am trying to get information from a worksheet Where I have created a Form to gather information and have that information copied into another worksheet to store. I am using two Excel VBA modules to perform this actions. In module1 my macro is collecting all of my data and the calls for the opening of the second of my two macros in module2 to copy that data into my second worksheet where i plan to store it. I test run my first VBA macro and all worked as expected with collecting the data. The problem I am having is in my second macro. I Dim all my variables and Set all my worksheets. When I run the macro it stops at the command line that should find my "nextRow= command" with the Application-defined or Object-defined error code '1004'.
Dim sourceSheet As Worksheet
Dim dataSheet As Worksheet
Dim nextRow As Integer
Set sourceSheet = Sheets("Form")
Set dataSheet = Sheets("Data")
nextRow = dataSheet.Range("A" & dataSheet.Rows.Count).End(x1Up).Offset(1).Row
dataSheet.Cells(nextRow, 1).Value = sourceSheet.Range("F5").Value
dataSheet.Cells(nextRow, 2).Value = sourceSheet.Range("F7").Value
The nextRow command you see is where my program stops.
This is my firs time writing code. I thought I understood it enough to solve this problem but I guess not. Any help will be greatly appreciated and a Thank you in advance for that help.
Dim sourceSheet As Worksheet
Dim dataSheet As Worksheet
Dim nextRow As Integer
Set sourceSheet = Sheets("Form")
Set dataSheet = Sheets("Data")
nextRow = dataSheet.Range("A" & dataSheet.Rows.Count).End(x1Up).Offset(1).Row
dataSheet.Cells(nextRow, 1).Value = sourceSheet.Range("F5").Value
dataSheet.Cells(nextRow, 2).Value = sourceSheet.Range("F7").Value
The nextRow command you see is where my program stops.
This is my firs time writing code. I thought I understood it enough to solve this problem but I guess not. Any help will be greatly appreciated and a Thank you in advance for that help.