To accomplish this in Excel, you can use VBA code and a timer event.
First, create your form button on the Job Request Sheet and go to the VBA Editor by pressing Alt+F11. Add a new module and paste the following code:
Public Sub SubmitFormAndCopy()
' Get the selected value from the list
Dim selectedValue As String
selectedValue = Range("B2").Value ' Change to your cell location
' Perform calculations based on the selected value
' Replace this with your own calculation code
' Wait for 4 seconds
Application.Wait Now + TimeValue("0:00:04")
' Get the sheet name from I2
Dim sheetName As String
sheetName = Range("I2").Value
' Get the data from column J of the specified sheet
Dim data As Variant
data = Worksheets(sheetName).Range("J:J").Value
' Create a new text document
Dim doc As Object
Set doc = CreateObject("Word.Document")
doc.Application.Visible = True
' Iterate through the data and append each value as a new line in the document
Dim i As Long
For i = 1 To UBound(data)
If Not IsEmpty(data(i, 1)) Then ' Exclude empty cells
doc.Content.InsertAfter data(i, 1) & vbNewLine ' Add a newline character
End If
Next i
' Activate the text document
doc.Activate
End Sub
This code is similar to the Google Apps Script code, but with some differences in syntax. It first gets the selected value from the form button and performs any necessary calculations, and then waits for 4 seconds using the Application.Wait method.
Next, it retrieves the sheet name from cell I2 and gets all the data from column J of that sheet using Worksheets.Range().Value.
The code creates a new text document using CreateObject("Word.Document") and then iterates through the data, appending each value as a new line in the document using InsertAfter.
Finally, the code activates the new text document using Activate.
Now, go back to the Job Request Sheet and add a timer event by right-clicking on the sheet tab and selecting "View Code". In the VBA Editor, select "Worksheet" from the dropdown at the top left and "Timer" from the dropdown at the top right. Then, paste the following code:
Private Sub Worksheet_Timer()
Call SubmitFormAndCopy
Me.TimerInterval = 0 ' Stop the timer after one execution
End Sub
This code sets up a timer that calls the SubmitFormAndCopy function and stops the timer after one execution by setting the TimerInterval property to 0.
Now, go back to the Job Request Sheet and right-click on the form button. Select "Assign Macro" and select the SubmitFormAndCopy macro from the list.
When you click the form button, the code will execute and open a new text document with the copied values. The timer event will automatically start after the code execution and will execute the same code after a certain interval (depending on the TimerInterval property value).
Note: You may need to enable the Microsoft Word Object Library to use CreateObject("Word.Document"). To do this, go to Tools -> References in the VBA Editor and select "Microsoft Word Object Library".