Click here to Skip to main content
14,643,054 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have the following Excel VBA statement:
Set yRange = Application.InputBox("select Y range and labels", "y range", , , , , , 8)

I want to implement the same action in a C# excel addin I am developing. That is, I want to set a range object to the cells highlighted in a spreadsheet. Any ideas?

What I have tried:

I've searched on C# Excel InputBox, C# select range and several related searches.
Posted
Updated 14-Oct-18 3:55am
Rate this:
Please Sign up or sign in to vote.

Solution 1

Your Google-fu needs work.

C# InputBox[^]
   
Comments
Fred Andres 13-Oct-18 10:23am
   
Thanks for the solution and new word to. Google-fu. I like it.
Dave Kreskowiak 13-Oct-18 10:26am
   
:)
Rate this:
Please Sign up or sign in to vote.

Solution 2

Here's what I did and it worked. The input box returns an Excel range.
Excel.Workbook p_book
private void get_data()
{
    Excel.Range Y_range;
    Excel.Range X_range;
    object missing = Type.Missing;
    Y_range = p_book.Application.InputBox
        ("select Y range", "y range", missing, missing, missing,
        missing, missing, 8);
    X_range = p_book.Application.InputBox
        ("select X range", "x range", missing, missing, missing,
        missing, missing, 8);
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100