Create a named range from an inputbox

Viewed 37

I´m trying to create a named range from an inputbox in VBA. This is the code that I have but I can´t get VBA to recognize the name of the range.

Dim xRgl As Range
Set xRg1 = Application.InputBox("Range A:", "Select Range", xTxt, , , , , 8)
Range("xRgl").Font.Italic = True
1 Answers

The issue is that you need to specify the object that the user inputs as a range. Try this:

Sub Testing()
    Dim xRgl As Range
    Set xRg1 = Application.InputBox("Range:", Type:=8)
    xRg1.Font.Italic = True
End Sub
Related