Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5964383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:25:19+00:00 2026-05-22T19:25:19+00:00

I want to implement this method in my c# program. But I am having

  • 0

I want to implement this method in my c# program. But I am having trouble filling in the appropriate parameters in a line like

long FirstRow = myWorksheet.Cells.Find(
  What:="*", 
  After:=Range("IV65536"), 
  LookIn:=xlValues,
  LookAt:= xlPart, 
  SearchOrder:=xlByRows,
  SearchDirection:=xlNext).Row

Here is the documentation for the Range.Find method.

Range Find(
    [In] object What, 
    [In, Optional] object After, 
    [In, Optional] object LookIn, 
    [In, Optional] object LookAt, 
    [In, Optional] object SearchOrder, 
    [In, Optional] XlSearchDirection SearchDirection, 
    [In, Optional] object MatchCase, 
    [In, Optional] object MatchByte, 
    [In, Optional] object SearchFormat
);

So basically I don’t know how to make the appropriate parameter objects.

Update
Excel.Range range;

        object What = "*";
        object After = xlWorkSheet.get_Range("A1", "IV65536");
        object LookIn = "xlValues";
        object LookAt = "xlPart";
        object SearchOrder = "xlByRows";
        Excel.XlSearchDirection SearchDirection = Excel.XlSearchDirection.xlNext;
        object MatchCase = System.Reflection.Missing.Value;
        object MatchByte = System.Reflection.Missing.Value;
        object SearchFormat = System.Reflection.Missing.Value;

        range = xlWorkSheet.Cells.Find(
            What,
            After,
            LookIn,
            LookAt,
            SearchOrder,
            SearchDirection,
            MatchCase,
            MatchByte,
            SearchFormat
            );

Gives a “COMException was unhandled: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))”

Update #2
Here is the method so far. The only thing missing is to set and return the range.

    public void RealUsedRange()
    {
        int FirstRow = xlWorkSheet.Cells.Find(
            "*",
            xlWorkSheet.get_Range("IV65536", misValue),
            Excel.XlFindLookIn.xlValues,
            Excel.XlLookAt.xlPart,
            Excel.XlSearchOrder.xlByRows,
            Excel.XlSearchDirection.xlNext,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value
            ).Row;

        int FirstColumn = xlWorkSheet.Cells.Find(
            "*",
            xlWorkSheet.get_Range("IV65536", misValue),
            Excel.XlFindLookIn.xlValues,
            Excel.XlLookAt.xlPart,
            Excel.XlSearchOrder.xlByColumns,
            Excel.XlSearchDirection.xlNext,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value
            ).Column;

        int LastRow = xlWorkSheet.Cells.Find(
            "*",
            xlWorkSheet.get_Range("IV65536", misValue),
            Excel.XlFindLookIn.xlValues,
            Excel.XlLookAt.xlPart,
            Excel.XlSearchOrder.xlByRows,
            Excel.XlSearchDirection.xlPrevious,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value
            ).Row;

        int LastColumn = xlWorkSheet.Cells.Find(
            "*",
            xlWorkSheet.get_Range("IV65536", misValue),
            Excel.XlFindLookIn.xlValues,
            Excel.XlLookAt.xlPart,
            Excel.XlSearchOrder.xlByColumns,
            Excel.XlSearchDirection.xlPrevious,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value,
            System.Reflection.Missing.Value
            ).Column;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:25:20+00:00Added an answer on May 22, 2026 at 7:25 pm

    Not tested but this gives you the general idea:

    long firstRow = myWorkSheet.Cells.Find(
        "*", /* What */
        Range("IV65536"), /* After */
        Excel.XlFindLookIn.xlValues, /* LookIn */
        Excel.XlLookAt.xlPart, /* LookAt */
        Excel.XlSearchOrder.xlByRows, /* SearchOrder */
        Excel.XlSearchDirection.xlNext, /* SearchDirection */
        Type.Missing, /* MatchCase */
        Type.Missing, /* MatchByte */
        Type.Missing /* SearchFormat */
        ).Row;
    

    Since you can’t use the optional argument syntax of VB.NET without C# v4, you need to supply all the arguments in order. Supplying null might work for missing args but I’m pretty sure Type.Missing is the right filler. Other than that it’s just calling it like you would expect.

    Here are some complete C# examples:

    • How to: Search for Text in Worksheet Ranges
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement something like Col3 = Col2 + Col1 in SQL. This
I saw this topic and implement IntentService as describes, but what if I want
I'm trying to implement a program in Xcode that's somewhat like a command line.
First, I know about Clog , and I do not want to implement this
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
I want to implement my own clustering algorithm using this Virtual Earth javascript API:
I want to implement an apperance as this article mentioned using nested ListView control.
I have this algorithm that I want to implement on VB6. Sub Main() dim
I want to implement a progress bar showing elapsed seconds in bash. For this,
I want to implement DropTargetListener with a JTable as a target. This is roughly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.