I have a workbook coded to collect info from it and transfer the data to a summary workbook. The code works when collecting the data but it prints the data to workbook the data is collected from, not the summary workbook. Its weird because it opens the summary workbook and even counts the row so the data will go to the first empty row. Can someone tell me what I'm doing wrong?
Dim WB1 as workbook
Dim MyData as workbook
Dim Assignment as string
Dim RowCount as integer
Set WB1 = ThisWorkbook
Assignment = Cells(45, "C")
WB1.Save
Set Mydata= Workbooks.Open (*File path to summary data document*)
MyData.Worksheets("Sheet1").Select
Worksheets("Sheet1").Range("a1").Select
RowCount = Worksheets("Sheet1").Cells(Rows.Count, "c").End(xlUp).Row + 1
With MyData.Worksheets("Sheet1").Range("A1")
Cells(RowCount, "b") = Assignment
End With
MyData.Save
End Sub
@Nathan_Sav notice where the problem is, but not exactly what the problem is..
You are missing one dot from Cells(RowCount, "b"). Without the dot before this, is like you are not using With, referring the ActiveSheet range only.
I believe this should work:
Disclaimer: this should resolve which workbook/worksheet your data is added to, not necessarily that is the correct range... but it should give you an idea on what to do next. Hope it helps :)
Cells(RowCount, "b") = Assignment
needs to be likeNot sure on the resize this pasting region.