Click here to Skip to main content
15,917,632 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
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

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);
}
 
Share this answer
 
Your Google-fu needs work.

C# InputBox[^]
 
Share this answer
 
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    
:)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900