Hi, how do i simply "create a named range using the input box" without further action for the purposes of advanced filter criteria usage? Many thanks in advance
This is the code i have but i can't seem to get the worksheet name to make the named range valid: Sub SelRange() 'Use InputBox to prompt user for range. 'Test for cancel and a single-cell selection. Dim rng As Range On Error Resume Next Set rng = Application.InputBox( _ Title:="Please select a range", _ Prompt:="Select range", _ Type:=8)
Dim iName As String iName = InputBox("Enter Name for the Selection.") ActiveSheet.Names.Add Name:=iName, RefersTo:=rng.Address On Error GoTo 0 'Test for cancel. If rng Is Nothing Then Exit Sub 'Test for single-cell selection. 'Comment out if single-cell selection is okay. If rng.Rows.Count = 1 Then MsgBox "You've selected only one cell." _ & "Please select multiple contiguous cells.", vbOKOnly Exit Sub End If 'Remove comment to select input range. 'rng.Select MsgBox rng.Address End Sub
i used on error resume next and on error goto 0 but when i click on cancel it shows "RUN Time Error 424" Object Required.. i am using office 365 .. what to do?? i dont want prompt this msg to user. pls help
Very thorough and carefully thought about all the possibilities. Great work.
hi sir, what is macro use this mode to copy data to others worksheet?
Hi, how do i simply "create a named range using the input box" without further action for the purposes of advanced filter criteria usage? Many thanks in advance
This is the code i have but i can't seem to get the worksheet name to make the named range valid:
Sub SelRange()
'Use InputBox to prompt user for range.
'Test for cancel and a single-cell selection.
Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox( _
Title:="Please select a range", _
Prompt:="Select range", _
Type:=8)
Dim iName As String
iName = InputBox("Enter Name for the Selection.")
ActiveSheet.Names.Add Name:=iName, RefersTo:=rng.Address
On Error GoTo 0
'Test for cancel.
If rng Is Nothing Then Exit Sub
'Test for single-cell selection.
'Comment out if single-cell selection is okay.
If rng.Rows.Count = 1 Then
MsgBox "You've selected only one cell." _
& "Please select multiple contiguous cells.", vbOKOnly
Exit Sub
End If
'Remove comment to select input range.
'rng.Select
MsgBox rng.Address
End Sub
i used on error resume next and on error goto 0 but when i click on cancel it shows "RUN Time Error 424" Object Required.. i am using office 365 .. what to do?? i dont want prompt this msg to user. pls help
have you declared the variable that gets highlighted during the error?