InputBox to Choose Array

  • I want to run a Macro in one spreadsheet that allows the user (who is not computer literate) to select an array of assignments from a spreadsheet where they are listed from A1:B27 with names in Col "A" and Assignments in Col "B".


    When I run the code, I get the InputBox, which allows me highlight the range of cells run-time error '424': Object Required

    Code
    Dim AssignmentArray As Variant 
    Dim rng As Range 
    Set rng = Application.InputBox(prompt:="Select Assignments from worksheet", Type:=64) 
    
    AssignmentArray = rng.value 

    I feel like I could debug something that was entered into rng, but since the highlighted cells aren't passed into rng I don't have anything to work through. I believe that I need to specify another object but I don't know what/how.


    Many Thanks

  • As you're using type 64 try

    Code
    Dim AssignmentArray As Variant
    AssignmentArray = Application.InputBox(prompt:="Select Assignments from worksheet", Type:=64)
  • When I change the accepting variable type to variant, I get error '13' type mismatch.

  • Thank you! I kept "Set" when I didn't need to keep it...

    Code
    Set AssignmentArray= 
    'I needed to use 
    AssignmentArray = 

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!