I made a code to copy data from one workbook to another and although that works I'm stuck on the next step. For the next step I need the data entered in a specific cell to go into a separate worksheet in the opened workbook but it would go into a different column based on the data entered into that cell.
The first part works and it pastes the data into the other workbook as intended, but I'm stumped at the second half and what I could do to have the data paste into the specific columns on the separate worksheet.
VBA Code:
Dim wb As Workbook, NR As Long
Set copySheet = Worksheets("AUForm")
Set wb = Workbooks.Open("C:\QA\Ryan\Holds_Test\AUDatabase.xlsm")
NR = Sheets("Database").Range("A" & Rows.Count).End(xlUp).Row + 1
Set pasteSheet = Worksheets("QCR")
With ThisWorkbook.Sheets("AUForm")
wb.Sheets("Database").Range("A" & NR).Value = .Range("F21").Value
wb.Sheets("Database").Range("B" & NR).Value = .Range("F11").Value
wb.Sheets("Database").Range("C" & NR).Value = .Range("F12").Value
wb.Sheets("Database").Range("D" & NR).Value = .Range("F13").Value
wb.Sheets("Database").Range("E" & NR).Value = .Range("F14").Value
wb.Sheets("Database").Range("F" & NR).Value = .Range("F15").Value
wb.Sheets("Database").Range("G" & NR).Value = .Range("F16").Value
wb.Sheets("Database").Range("H" & NR).Value = .Range("F17").Value
wb.Sheets("Database").Range("I" & NR).Value = .Range("F18").Value
wb.Sheets("Database").Range("J" & NR).Value = .Range("F19").Value
wb.Sheets("Database").Range("K" & NR).Value = .Range("F20").Value
If ThisWorkbook.Sheets("AUForm").Range("F6") = "AU1" Then
wb.Sheets("QCR").Range("A" & NR).Value = .Range("F21").Value
ElseIf ThisWorkbook.Sheets("AUForm").Range("F6") = "AU2" Then
wb.Sheets("QCR").Range("B" & NR).Value = .Range("F21").Value
ElseIf ThisWorkbook.Sheets("AUForm").Range("F6") = "AU3" Then
wb.Sheets("QCR").Range("C" & NR).Value = .Range("F21").Value
End If
End With
wb.Close savechanges:=True
Rows("21").EntireRow.Hidden = False
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
The first part works and it pastes the data into the other workbook as intended, but I'm stumped at the second half and what I could do to have the data paste into the specific columns on the separate worksheet.