vba pause while the user paste a list into a sheet

jscranton

Well-known Member
Joined
May 30, 2011
Messages
707
I have some code that asks the user to paste a list into the active sheet.

I want the code to allow time for the user to do and then either restart or prompt the user to click ok if they are done.

Any suggestions?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
What kind of user form allows the user to interact with the active sheet before clicking okay?
 
Upvote 0
I created a form and changed Show Modal to false. That allows the user to paste (which is great). But, I want the code to resume when they click okay (Case 1). As it is now, the box stays open until the entire code is complete.

here is my code (and thanks for the help).

Code:
Sheets("PasteTeamList").Visible = True
        Sheets("PasteTeamList").Select
 
        On Error Resume Next
 
        Set myForm = formCustomMsgBox2
            myForm.Caption = "Paste Team List"
            myForm.Show
 
 
        Select Case myForm.Tag
 
            Case 1
 
                LR = (Sheets("PasteTeamList").Range("A" & Rows.Count).End(xlUp).Row) - 1
 
                    For i = 1 To LR
 
                            teamList(i) = CStr(Sheets("PasteTeamList").Range("A" & i).Value)
 
                        Next i
 
 
 
 
            End Select
 
    Sheets("PasteTeamList").Visible = False
 
Upvote 0
Why not create an on click function for the OK button? It could form.Hide then continue the code.
 
Upvote 0
would a timer work?

standard module:
Code:
Dim RunAt As Date
Const CycSecs As Integer = 1

Sub Button1_Click()
    'adapt here for your code
    Range("A7") = ""
    myForm.Show vbModeless
End Sub

Sub CheckPasteArea()
    If Range("A7") = "" Then
        TimerStart
    Else
        TimerStop
        Unload myForm
    End If
End Sub

Sub TimerStart()
    RunAt = Now + TimeSerial(0, 0, CycSecs)
    Application.OnTime _
        EarliestTime:=RunAt, _
        Procedure:="CheckPasteArea"
End Sub

Sub TimerStop()
    On Error Resume Next
        Application.OnTime _
            EarliestTime:=RunAt, _
            Procedure:="CheckPasteArea", _
            Schedule:=False
    On Error GoTo 0
End Sub

UserForm:
Code:
Private Sub UserForm_Activate()
    TimerStart
End Sub
 
Upvote 0
What if I add a list box to my command button?

Is it easy to have the user paste the list into there and once they click okay, transfer it to the active sheet?
 
Upvote 0
I don't think a list box would work. A multi line text box would be fine.
 
Upvote 0
I bailed on the user form since it doesn't seem necessary with a timer.The goal below is to run the timer for a bit then return to the condition. but, it keeps throwing an endless loop.

Code:
Sub createTeamArray()
    ReDim teamList(1 To 500) As String
    Dim i As Long
    Dim myForm As formCustomMsgBox2
 
    totalReviewers = 25
 
 
 
    checkEntryMethod = MsgBox("We need to set up a reviewer list for your " & CStr(totalReviewers) & " person review team. If you want to paste a list, select yes. To enter manually, select no.", vbYesNo)
 
    If checkEntryMethod = vbNo Then
 
        For i = 1 To totalReviewers
 
            teamArray(i) = InputBox("What is the name of your first review in format FirstName M. LastName?")
 
        Next i
 
    Else
 
        Sheets("PasteTeamList").Visible = True
        Sheets("PasteTeamList").Select
 
        On Error Resume Next
 
 
    Call checkPasteArea
 
 
    Sheets("PasteTeamList").Visible = False
 
    End If
 
 
End Sub
Sub checkPasteArea()
 
1:    If Sheets("PasteTeamList").Range("A" & totalReviewers) = "" Then
 
        Application.OnTime Now + TimeValue("00:00:45"), "TeamArray"
        GoTo 1
      Else
 
            LR = (Sheets("PasteTeamList").Range("A" & Rows.Count).End(xlUp).Row) - 1
 
                    For i = 1 To LR
 
                            teamList(i) = CStr(Sheets("PasteTeamList").Range("A" & i).Value)
 
                        Next i
        End If
 
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,491
Messages
6,055,727
Members
444,814
Latest member
AutomateDifficulty

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top