Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Type mismatch

TIM wrote:
I get run time error 13
type mismatch
from this line of code in VB

Cells(cLastRow + 1, "B").Value = Cells(cLastRow, "B").Value + 1


is cLastRow a number?

my first two tests work OK herehe

Sub test()
Dim cLastRow As Long
cLastRow = 7
Cells(cLastRow + 1, "B").Value = Cells(cLastRow, "B").Value + 1
End Sub

Sub test2()
Dim cLastRow As String
cLastRow = "7"
Cells(cLastRow + 1, "B").Value = Cells(cLastRow, "B").Value + 1
End Sub

test3, not surprisingly, produces a type mismatch

Sub test3()
Dim cLastRow As String
cLastRow = "G"
Cells(cLastRow + 1, "B").Value = Cells(cLastRow, "B").Value + 1
End Sub


--
Steve Garman

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
Type mismatch... George[_4_] Excel Discussion (Misc queries) 7 December 19th 07 12:20 PM
type mismatch--how to fix rroach Excel Discussion (Misc queries) 2 July 14th 05 06:23 PM
Type mismatch Alan Beban[_4_] Excel Programming 0 February 4th 04 08:39 PM
Type Mismatch Phil Hageman[_3_] Excel Programming 2 January 9th 04 06:11 PM


All times are GMT +1. The time now is 12:45 AM.

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

About Us

"It's about Microsoft Excel"