LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Runtime Error 13 - Type Mis-match

Hi, I inherited this macro. Since we have migrated to XP and Excel 2003, we
are getting a Runtime Error 13 - Type Mis-match on the following line of
code.

dat = Replace(Sheets(Worksheets.Count - 2).Name, ".", "/")

Does anyone have any ideas on how to fix it? It looks like it should be a
string.

Thanks in advance.
-Kim

-----------------------------------
Sub DBandReportPageSetup()
' Macro1 Macro

' DataBase and Reports page setup
' This Macro also sort Database and Reports data

'---------------------------------------- Declaration of
Variables------------------------------------------
Dim totcol, totlin, x, y, totlin2, totlinrp As Integer
Dim reportname As String
Dim dat As Date

'----------------------------------------- Database Page Setup
---------------------------------------------

' Application.DisplayAlerts = True

reportname = Sheets(Worksheets.Count - 1).Name
dat = Replace(Sheets(Worksheets.Count - 2).Name, ".", "/")


y = 0



If ActiveSheet.Name < reportname Then Sheets(reportname).Activate
totlinrp = Range("A65536").End(xlUp).Row
If ActiveSheet.Name < "DataBase" Then Sheets("DataBase").Activate
totlin = Range("B65536").End(xlUp).Row
totcol = Cells(2, Columns.Count).End(xlToLeft).Column
totlin2 = totlin + 1

Range(Cells(3, 1), Cells(totlin, totcol)).Select
Selection.Sort Key1:=Range("C3"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Interior.ColorIndex = 2
Selection.Font.FontStyle = "Regular"
Selection.Font.ColorIndex = xlAutomatic

For x = 3 To totlin
y = y + 1
Cells(x, 10).Value = UCase(Trim(Cells(x, 10).Value))
If Cells(x, 3).Value = dat Then
For z = 3 To totlinrp
If Cells(x, 1).Value = Sheets(reportname).Cells(z, 1).Value And
Sheets(reportname).Cells(z, 10).Value = 0 Then GoTo notred:
Next
Rows("3:3").Select
Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
Range(Cells(x + 1, 1), Cells(x + 1, 38)).Copy
Cells(3, 1).Select
ActiveSheet.Paste
Range(Cells(3, 1), Cells(3, 38)).Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
Range(Cells(x + 1, 1), Cells(x + 1, 38)).Select
Selection.Delete shift:=xlUp
End If
notred:

If Cells(x, 10).Value = "YES" And Cells(x, 3).Value < dat Or Cells(x,
10).Value = "ACCEPTABLE" Then
Range(Cells(x, 1), Cells(x, 38)).Copy
Cells(totlin2, 1).Select
ActiveSheet.Paste
Range(Cells(x, 1), Cells(x, 38)).Select
Selection.Delete shift:=xlUp
totlin = totlin - 1
x = x - 1
End If
If y = totlin2 - 1 Then GoTo suite:
Next
suite:
y = 0
For x = 3 To totlin
y = y + 1
If Cells(x, 2).Value = dat Then
Rows("3:3").Select
Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
Range(Cells(x + 1, 1), Cells(x + 1, 38)).Copy
Cells(3, 1).Select
ActiveSheet.Paste
Range(Cells(3, 1), Cells(3, 38)).Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
Range(Cells(x + 1, 1), Cells(x + 1, 38)).Select
Selection.Delete shift:=xlUp
End If
If y = totlin2 - 1 Then GoTo suite2:
Next
suite2:

totlin = Range("B65536").End(xlUp).Row
totcol = Cells(2, Columns.Count).End(xlToLeft).Column
Range(Cells(3, 1), Cells(totlin, totcol)).Select
Selection.VerticalAlignment = xlTop

With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range(Cells(3, 9), Cells(totlin, 9)).Select
Selection.WrapText = True
Range(Cells(3, 1), Cells(totlin, 1)).Select
Selection.HorizontalAlignment = xlLeft
Range(Cells(3, 2), Cells(totlin, 8)).Select
Selection.HorizontalAlignment = xlCenter
Selection.Font.Size = 9
Range(Cells(3, 10), Cells(totlin, 11)).Select
Selection.HorizontalAlignment = xlCenter
Selection.Font.Size = 9
Range(Cells(3, 9), Cells(totlin, 9)).Select
Selection.HorizontalAlignment = xlLeft
Selection.Font.Size = 7
Range(Cells(3, 12), Cells(totlin, 38)).Select
Selection.HorizontalAlignment = xlLeft
Selection.Font.Size = 7
Cells(3, 1).Activate

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
xpath error? Runtime Error 13 type mismatch Steve M[_2_] Excel Discussion (Misc queries) 0 January 17th 08 01:16 AM
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Runtime error 13 type mismatch ? JoeH[_17_] Excel Programming 1 September 25th 04 07:20 PM
Runtime error 13 type mismatch ? JoeH[_16_] Excel Programming 0 September 25th 04 06:44 PM


All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"