Results 1 to 3 of 3

Small Issue with Type Mismatch and Invalid Qualifier when setting variable value from cell

Threaded View

  1. #1
    Registered User
    Join Date
    02-02-2012
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    42

    Small Issue with Type Mismatch and Invalid Qualifier when setting variable value from cell

    Hello,

    I am haveing a small issue I am trying to set a variables value based on the value of a cell in a row that was searched for. Heres my code:

    Public Sub APF500MtoAPF511MCutList()
    Dim NSheet As Worksheet
    
    Set NSheet = Worksheets(NAAMSNAME)
    
    ' Find First cell in column F that has the value of the Global Variable "NAAMSNAME"
    Set S = NSheet.Range("F2:F" & Cells(Rows.Count, "F").End(xlUp).Row).Find(NAAMSNAME)
     If Not S Is Nothing Then
     
     'Set the Value of the Global Variable LengthNAAMS to the 7th cell over in "S" now that S has been found.
      LengthNAAMS = NSheet.Cells(S, 7).Value
      
      MsgBox LengthNAAMS '<--- Test to See if It kept stored the value properly.
     End If
    
    End Sub
    the Variable LengthNAAMS is set as a 'Long" (I have tried it as a string and I get the same error.)

    Right now it says Type Mismatch Error
    But if I change it to:
    LengthNAAMS.Value = NSheet.Cells(SRow, 7).Value
    It changes to Invalid Qulifer Error.

    I have also tried this:
    Public Sub APF500MtoAPF511MCutList()
    Dim NSheet As Worksheet
    Dim SRow As Range
    
    Set NSheet = Worksheets(NAAMSNAME)
    
    ' Find First cell in column F that has the value of the Global Variable "NAAMSNAME"
    Set S = NSheet.Range("F2:F" & Cells(Rows.Count, "F").End(xlUp).Row).Find(NAAMSNAME)
     If Not S Is Nothing Then
     SRow = S.EntireRow
     
     'Set the Value of the Global Variable LengthNAAMS to the 7th cell over in "S" now that S has been found.
      LengthNAAMS = NSheet.Cells(SRow, 7).Value
      
      MsgBox LengthNAAMS '<--- Test to See if It kept stored the value properly.
     End If
    
    End Sub
    But the error I get then is object variable or With Block variable not set.


    Not sure how to fix this. If the code doesn't make sense it is supposed to find a Value in Column F and set the variable "S" to that row than select the value of the 7 cell over in row "S" and set the Variable LengthNAAMS to the value of that cell.

    Anything is helpful ! Even a whole new way of doing this
    Last edited by TomToms; 10-10-2014 at 07:28 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Invalid Qualifier to a Valid Qualifier (Application)
    By exceltabz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2014, 11:31 AM
  2. [SOLVED] Invalid Qualifier
    By Antares19 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2012, 08:48 AM
  3. Compile Error: Invalid Qualifier in column sum/cell naming program
    By xioncrush in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2007, 12:35 AM
  4. Setting range object--Type mismatch if template not used
    By cbender@mriresearch.org in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2006, 12:25 PM
  5. Invalid Qualifier
    By Stuart in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-21-2005, 11:06 AM

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