Excel VBA To Allow User To Select A Range With An InputBox | Get input from the user using Input Box

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ต.ค. 2024

ความคิดเห็น • 6

  • @AdityaPillai009
    @AdityaPillai009 2 ปีที่แล้ว

    Very thorough and carefully thought about all the possibilities. Great work.

  • @samsurizal4957
    @samsurizal4957 ปีที่แล้ว

    hi sir, what is macro use this mode to copy data to others worksheet?

  • @adizon2
    @adizon2 2 ปีที่แล้ว

    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

    • @adizon2
      @adizon2 2 ปีที่แล้ว

      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

  • @sreejondey1917
    @sreejondey1917 3 ปีที่แล้ว

    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

    • @excelworld620
      @excelworld620  3 ปีที่แล้ว

      have you declared the variable that gets highlighted during the error?