Results 1 to 6 of 6

"ByRef argument type mismatch error" trying to use my first UDF

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    "ByRef argument type mismatch error" trying to use my first UDF

    I am stuck,

    I am only marginally familiar with arrays and I can not figure out how to deal with the "ByRef argument type mismatch error" the Sub gives because "Area" is a variant not a string

    Thanks

    Sub Area()
        Dim Areas As Variant
        Dim Area As Variant
    
        Areas = Array("K2:K", "R2:R", "Y2:Y", "AG2:AG")
    
        For Each Area In Areas
            If Not DoIHaveARange("XXX", Area, "Yes") Is Nothing Then 'Code
        Next Area
    
    End Sub
    Public Function DoIHaveARange(ShtName As String, Rng As String, FindWhat As String) As Range
    Dim ws As Worksheet
    Dim lRow As Long
    
     Set ws = ThisWorkbook.Sheets(ShtName)
      lRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
    
       Set DoIHaveARange = Range(Rng & lRow).Find(What:=FindWhat, LookIn:=xlFormulas, _
                     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                     False, SearchFormat:=False)
    End Function
    Last edited by capson; 05-23-2014 at 08:53 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] ByRef argument type mismatch / Passing array as a function argument
    By pzling in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2012, 06:23 PM
  2. Byref argument type mismatch
    By ref in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2012, 06:17 AM
  3. Error passing element of string array get ByRef argument type mismatch
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-17-2011, 02:59 PM
  4. "ByRef argument type mismatch" Error
    By Baapi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2005, 08:05 PM
  5. ByRef argument type mismatch error?
    By sermest in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2005, 02:05 PM

Tags for this Thread

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