如何让用户从对话框中input范围

所以我需要从用户范围,如何查询用户select范围,如“

dim x as range x = getrange("Select Range to Compare") msgbox "The range selected is " & x 

有没有办法做到这一点?

你可以尝试这样的事情。 根据您的要求调整它。

 Sub AskUserToSelectARangeToWorkWith() Dim Rng As Range On Error Resume Next Set Rng = Application.InputBox("Select a Range to compare.", "Select A Range!", Type:=8) If Rng Is Nothing Then MsgBox "You didn't select a Range.", vbCritical, "No Range Selected!" Exit Sub End If MsgBox "The Range selected is " & Rng.Address(0, 0) End Sub