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
Bookmarks