Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Runtime Error 13 - Mismatch

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Runtime Error 13 - Mismatch

absRowTot is of type double. If you try to assign text to that variable you
will get a type mismatch. Change it to type Variant as a quick and dirty
solution.
--
HTH...

Jim Thomlinson


"Mike C" wrote:

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Runtime Error 13 - Mismatch

Dim absRowTot As Variant

instead of Double.

If this post helps click Yes
---------------
Jacob Skaria


"Mike C" wrote:

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Runtime Error 13 - Mismatch

Another question...

Are there any errors in that range (column 20)?

If yes, you could use:

For i = topCell To bottomCell Step 1

if iserror(fim.cells(i,absrowtotcolumn).value) then
'skip it
else
'absrowtot is still declared a variant
absRowTot = fim.Cells(i, absRowTotColumn).Value

If absRowTot = 0 Then
For n = i To i
fim.Rows(n).Hidden = True
Next n
End If

end if
Next i


Ps. I would never use "as integer" in the declarations. I use "as long". They
hold bigger numbers (less change of problems) and from what I've read are
quicker on new pcs.



Mike C wrote:

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Runtime Error 13 - Mismatch

And you don't need this loop:

For n = i To i
fim.Rows(n).Hidden = True
Next n


fim.Rows(i).Hidden = True

Dave Peterson wrote:

Another question...

Are there any errors in that range (column 20)?

If yes, you could use:

For i = topCell To bottomCell Step 1

if iserror(fim.cells(i,absrowtotcolumn).value) then
'skip it
else
'absrowtot is still declared a variant
absRowTot = fim.Cells(i, absRowTotColumn).Value

If absRowTot = 0 Then
For n = i To i
fim.Rows(n).Hidden = True
Next n
End If

end if
Next i


Ps. I would never use "as integer" in the declarations. I use "as long". They
hold bigger numbers (less change of problems) and from what I've read are
quicker on new pcs.

Mike C wrote:

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Runtime Error 13 - Mismatch

If I make it a variant it still gives me a type mismatch error.


"Jim Thomlinson" wrote:

absRowTot is of type double. If you try to assign text to that variable you
will get a type mismatch. Change it to type Variant as a quick and dirty
solution.
--
HTH...

Jim Thomlinson


"Mike C" wrote:

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Runtime Error 13 - Mismatch

If I make it a variant it still gives me a type mismatch error.


"Jacob Skaria" wrote:

Dim absRowTot As Variant

instead of Double.

If this post helps click Yes
---------------
Jacob Skaria


"Mike C" wrote:

Below is the code I am using. The code is designed to hide zeros. Let me
know if anyone has any ideas or suggestions why it is not working. Thanks in
advance.
Mike C

Sub Toggle_Suppresion()

Dim i As Integer
Dim n As Integer
Dim wkb As Workbook
Dim wks As Worksheet
Dim fim As Worksheet
Dim rng As Range
Dim absRowTot As Double
Dim topCell As Integer 'The first Row in the report with data (must be
changed accordingly)
Dim bottomCell As Integer 'Bottom Row in the report (set automatically)
Dim absRowTotColumn 'The numeric column that has the absolute value
sumation


topCell = 8
bottomCell = ActiveSheet.UsedRange.Rows.Count
absRowTotColumn = 20

Set wks = ActiveCell.Worksheet
Set fim = ActiveSheet

Application.ScreenUpdating = False

'fim.Select
'Rows(topCell & ":" & bottomCell).Select
'Selection.EntireRow.Hidden = False


For i = topCell To bottomCell Step 1
absRowTot = fim.Cells(i, absRowTotColumn).Value


If absRowTot = 0 Then

For n = i To (i)
Rows(n).Select
Selection.EntireRow.Hidden = True
Next
End If
Next

fim.Select
Range("a1").Select

Application.ScreenUpdating = True


End Sub

Reply
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 Linking to specific cells in pivot table Excel Programming 2 May 18th 05 07:34 PM
Runtime error 13 type mismatch ? JoeH[_14_] Excel Programming 1 September 25th 04 04:57 PM


All times are GMT +1. The time now is 11:49 PM.

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"