Input Form to Get Data and Store it in Another Tab in Excel


Hello, referring to the article referenced in the title. Is is possible to have it report to 2 worksheets?

ws_output="Data" (and?) "Data2"



Selected Answer

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.



p.s.try to use the Add Link button in future posts to refer to a tutorial or similar. Be sure to put the URL between the inverted commas like the bold bit here "link_goes_here" and use paste plain text to replace Visible_Text.
John_Ru (rep: 1072) Apr 27, '21 at 4:23 pm
Yes, it helped. Now I have a second issue, I have an existing message that says "submitted". It now pops up twice, a way to avoid that?
Morgans (rep: 2) Apr 27, '21 at 4:38 pm

Thanks for selecting my Answer.

I don't get that isue so assume you added a MsgBox "Submitted" line to the tutorial macro. Suggest you make sure it's NOT in the Function code (since that is called twice) but following the two lines of the reduced Sub,
John_Ru (rep: 1072) Apr 27, '21 at 4:56 pm
Add to Discussion

Answer the Question

You must create an account to use the forum. Create an Account or Login