Hello, referring to the article referenced in the title. Is is possible to have it report to 2 worksheets?
ws_output="Data" (and?) "Data2"
Hello, referring to the article referenced in the title. Is is possible to have it report to 2 worksheets?
ws_output="Data" (and?) "Data2"
Hello Morgans and welcome to the Forum
You can't do that as you wrote but, if you want to add the same data to the bottom another,existing sheet called Data2, you could take all the lines from that macro and put them into a Function (and call that from your Sub). If you replace the code with this:
Sub data_input()
CopyToPage "Data"
CopyToPage "Data2"
End Sub
Function CopyToPage(ws_output As String)
next_row = Sheets(ws_output).Range("A" & Rows.Count).End(xlUp).Offset(1).Row
Sheets(ws_output).Cells(next_row, 1).Value = Range("first_name").Value
Sheets(ws_output).Cells(next_row, 2).Value = Range("last_name").Value
Sheets(ws_output).Cells(next_row, 3).Value = Range("email").Value
Sheets(ws_output).Cells(next_row, 4).Value = Range("account").Value
End Function
The main sub just calls the function CopyToPage with the line:CopyToPage "Data"
where the bit in bold is passed to the function (which it takes to mean what is called ws_output in the code). It then just does the same but passes the string Data2 to the function for action.
You can try it in the modified file attached
Hope this makes sense.