0
votes

Check out the following code:

Sub tickscale_table()

exch = Cells(I, 13).Value
Worksheets("tickscale").Activate
Range("A1").Activate


Cells.Find(What:=exch, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
    xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=True _
    , SearchFormat:=False).Activate

 If ms = ActiveCell.Offset(0, 1) And cr = ActiveCell.Offset(0, 3) Then
     tickscaletype = ActiveCell.Offset(0, 4).Value2 And tickcale = ActiveCell.Offset(0,5).Value2

End If

Above is the code I am trying to run to search for values in a excelsheet table and when this value is found in the first column I search if the values for ms and cr satisfy from the other column in the same row, if the conditions are true I make tickscaletype and tickscale equal to the values from the other column in the same row.

I am getting type mismatch for

tickscaletype=ActiveCell.Offset(0,4).value

I have tried declaring tisckscaletype and tickscale as variant, range, string, leaving empty, but still getting the error.

1

1 Answers

2
votes

This bit of code doesn't make sense to me

tickscaletype = ActiveCell.Offset(0, 4).Value2 And tickcale = ActiveCell.Offset(0,5).Value2

You should have

tickscaletype = ActiveCell.Offset(0, 4).Value2 
tickcale = ActiveCell.Offset(0,5).Value2