+ Reply to Thread
Results 1 to 2 of 2

Type mismatch error in Excel

  1. #1

    Type mismatch error in Excel

    Hello,
    I receive a type-mismatch error when compiling. The cells being
    referenced only have dates. Can someone help? Heres some of the code

    Application.Windows("rpt_BigTicket.xls").Activate
    a = Range("D:J")
    b = DateValue(Format(Now(), "mm-dd-yyyy")) - Weekday(Now(), 1)
    c = Application.VLookup(b, a, 2, False) "This is where the ERROR-13
    'Tpye Mismatch occurs'


  2. #2
    JE McGimpsey
    Guest

    Re: Type mismatch error in Excel

    The default property for a range is the .Value property, so

    a = Range("D:J") is returning an array of values, not a range object.

    Try something like:

    Dim a As Range
    Dim b As Long
    Dim c As Variant
    Application.Windows("rpt_BigTicket.xls").Activate
    Set a = ActiveSheet.Range("D:J")
    b = CLng(Date - WeekDay(Date, 1))
    c = Application.VLookup(b, a, 2, False)

    In article <[email protected]>,
    "[email protected]" <[email protected]> wrote:

    > Hello,
    > I receive a type-mismatch error when compiling. The cells being
    > referenced only have dates. Can someone help? Heres some of the code
    >
    > Application.Windows("rpt_BigTicket.xls").Activate
    > a = Range("D:J")
    > b = DateValue(Format(Now(), "mm-dd-yyyy")) - Weekday(Now(), 1)
    > c = Application.VLookup(b, a, 2, False) "This is where the ERROR-13
    > 'Tpye Mismatch occurs'


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1