Q:

VBA : InputBox wrongly used previous User Input without prompting for new input

This is the VBA code I am learning to write (got some reference from the Internet)
Public whatyousay As String

Sub testing()

b14
b15

End Sub

Function WorksheetExists(WSName As String) As Boolean

    On Error Resume Next
    WorksheetExists = Worksheets(WSName).Name = WSName
    On Error GoTo 0

End Function

Sub b14()

Dim sh As Worksheet

Do Until WorksheetExists(whatyousay)
    whatyousay = InputBox("Enter sheet name")
    If Not WorksheetExists(whatyousay) Then MsgBox whatyousay & " doesn't exist.", vbExclamation
Loop
If WorksheetExists(whatyousay) Then Sheets(whatyousay).Activate

End Sub

Sub b15()

ThisWorkbook.Worksheets(whatyousay).Range("A1").Value = xxxx

End Sub

I must have wrongly adjust the code, as I can't find anyone having the same problem on the Internet.
When the button is clicked, it is supposed to prompt user input for the sheet name, then perform some actions.
Now, the problem I am facing is that the button only prompt user input for one time. If it was clicked the second time, it will used the previous user input without prompting.
Can anyone of you please point me to the right direction?

A:

You are not erasing what was left in whatyousay during the last loop.
Sub b15()

    ThisWorkbook.Worksheets(whatyousay).Range("A1").Value = xxxx
    whatyousay = vbnullstring      '<~~ remove the string from last time

End Sub

Personally, I avoid public vars. You can do the same thing by passing the string var into the secondary sub as a parameter.

