Is there a command equivalent to readLine of Java in VBA. I want to use the text input in the immediate window and put it in a variable. Is it possible?
You can't use the Immediate Window interactively. For one thing -- while a sub is running it won't accept any keyboard input. You can, however, use it to pass data to a sub or function when you invoke it, so in a sense you can "scrape" data that is there already. Something along these lines:
Sub AddNums(ParamArray nums())
Dim total As Double
Dim i As Long
For i = 0 To UBound(nums)
total = total + nums(i)
Next i
Debug.Print total
End Sub
For example:
Beyond that -- you could move the input-gathering phase to a VBScript script running in console mode, invoke it from VBA, and use either a file (which the script writes to) or perhaps the clipboard to get the data from the script after it is done running. This should be feasible, though it is probably better to find a more idiomatic (form-based) way to do it within VBA.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With