View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] scotto56@gmail.com is offline
external usenet poster
 
Posts: 1
Default Type Mismatch Error in Excel VBA when looping through worksheets

Check the FOR NEXT Loop - four lines into loop (see *****...)- getting
type mismatch error - any thoughts/advice appreciated. Just looping
though selecting columns and then two additional columns without the
headers. Eventually in order to change to Proper Case. Thanks! -
Scott

Application.ScreenUpdating = False
Dim myRng As Range
Dim myArea As Range
Dim wsSheet As Worksheet
On Error Resume Next

For Each wsSheet In Worksheets
wsSheet.Select
Set myRng = Range("D:D,E:E,I:I,J:J,N:N,O:O,P:P,Q:Q,Y2:Z2")
myRng.Select
' *********THESE NEXT TWO LINES WILL CAUSE THE ERROR 13 - TYPE
MISMATCH
myRng("Y2").Activate
myRng(Selection, Selection.End(xlDown)).Select

If myRng Is Nothing Then
MsgBox "Nothing in intersect range"
Else
For Each myArea In myRng.Areas
myArea.Formula = Application.Proper(myArea.Formula)
Next myArea
End If

Range("A1").Select
Next wsSheet

Application.ScreenUpdating = True

Sheets("Master").Select