Run-Time Error 13 Type Mismatch

rletarte

New Member
Joined
Apr 21, 2011
Messages
4
HI all!

This is my very first post, so hopefully all information you need is here.

I keep getting a runtime error on the following highlighted in red.

Sub UpdateSubsChoosing()

'Runs through and replaces text "Sold Out" with the subs info from Subs Choosing sheet

Dim myRange As Range
Dim myCell As Range


If MsgBox("THIS WILL REPLACE EVERY " & "'" & "SOLD OUT" & "'" & " WITH THE SUBSTITUTION TEXT FROM THE " & vbCrLf & vbCrLf & _
"'" & "SUBS CHOOSING" & "'" & " Excel worksheet for the SPRING 2011 SEASON." & vbCrLf & vbCrLf & _
"DO YOU WANT TO CONTINUE?", vbYesNo, "REPLACING SOLD OUT WITH SUBS") = vbNo Then
Exit Sub
Else

Set myRange = Range("A1:AG500")
For Each cell In myRange
If Trim(UCase(cell.Value)) = "SOLD OUT" Then
cell.Font.FontStyle = Regular
cell.Value = "=IF(VLOOKUP(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),'O:\Shipping\Forms, Slips, Labels, Charts\Subbing Forms\Subs Choosing & Tally Spring\[Subs Choosing Spring 2011.xlsm]Subs - MODIFY'!$A$1:$C$500,3,FALSE)=" & """" & """" & "," & """" & "S/O" & """" & ",VLOOKUP(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),'O:\Shipping\Forms, Slips, Labels, Charts\Subbing Forms\Subs Choosing & Tally Spring\[Subs Choosing Spring 2011.xlsm]Subs - MODIFY'!$A$1:$C$500,3,FALSE))"

End If
Next cell
End If

End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try

Code:
For Each cell In myRange
    If cell.Value <> "" Then
        If Trim(UCase(cell.Value)) = "SOLD OUT" Then
            cell.Font.FontStyle = Regular
            cell.Value = "=IF(VLOOKUP(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),'O:\Shipping\Forms, Slips, Labels, Charts\Subbing Forms\Subs Choosing & Tally Spring\[Subs Choosing Spring 2011.xlsm]Subs - MODIFY'!$A$1:$C$500,3,FALSE)=" & """" & """" & "," & """" & "S/O" & """" & ",VLOOKUP(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),'O:\Shipping\Forms, Slips, Labels, Charts\Subbing Forms\Subs Choosing & Tally Spring\[Subs Choosing Spring 2011.xlsm]Subs - MODIFY'!$A$1:$C$500,3,FALSE))"
        End If
    End If
Next cell
 
Upvote 0
Maybe

Code:
For Each cell In myRange
    If Not IsError(cell) Then
        If cell.Value <> "" Then
            If Trim(UCase(cell.Value)) = "SOLD OUT" Then
                cell.Font.FontStyle = Regular
                cell.Value = "=IF(VLOOKUP(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),'O:\Shipping\Forms, Slips, Labels, Charts\Subbing Forms\Subs Choosing & Tally Spring\[Subs Choosing Spring 2011.xlsm]Subs - MODIFY'!$A$1:$C$500,3,FALSE)=" & """" & """" & "," & """" & "S/O" & """" & ",VLOOKUP(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,-2),'O:\Shipping\Forms, Slips, Labels, Charts\Subbing Forms\Subs Choosing & Tally Spring\[Subs Choosing Spring 2011.xlsm]Subs - MODIFY'!$A$1:$C$500,3,FALSE))"
            End If
        End If
    End If
Next cell
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

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