Getting Type Mismatch Error with higher column numbers

Felix1980

New Member
Joined
May 16, 2018
Messages
40
Hello, I am trying to search data in column AX but my code keeps giving me the Type Mismatch error anytime I raise the column from AF on the If statement. AF works, AG does not. I'm very confused, please help!

VBA Code:
Sub tester()

Dim wb As Workbook
Dim OVERVIEW As Worksheet
Dim ORDER As Worksheet
Dim j As Long
Dim AnmType As Range
Dim OLrow As Long
Dim OFrow As Long
Dim p As Long

Set wb = ActiveWorkbook
Set OVERVIEW = wb.Sheets("Overview")
Set ORDER = wb.Sheets("BreakDownOrders")
OLrow = ORDER.Cells(ORDER.Rows.Count, "A").End(xlUp).Row

OFrow = ORDER.Cells(2, 1)
p = OVERVIEW.Range("A23")
Set AnmType = ORDER.Range("A2:BB" & OLrow)

    For j = 2 To OLrow
  
      '  If ORDER.Cells(j, 34).Value = "Whole" And ORDER.Cells(j, 1) = OVERVIEW.Cells(1, 1) Then
      If ORDER.Range("AX" & j).Value = "Whole" Then

         '   OVERVIEW.Cells(p, 1).Value = ORDER.Cells(j, 3).Value
         '   OVERVIEW.Cells(p, 2).Value = ORDER.Cells(j, 52).Value
         '   p = p + 1
    Else

     'next thing

         End If
 
    Next j

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Do you have any error values in columns AG onwards?
 
Upvote 0
There are no formulas, but there are some cells with the text #N/A. Will just the text in the cells cause that problem?
 
Upvote 0
Will just the text in the cells cause that problem?
That text will, yes. Try making this change

Rich (BB code):
If ORDER.Range("AX" & j).Value = "Whole" Then
If ORDER.Range("AX" & j).Text = "Whole" Then
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top