Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch problem 1

Status
Not open for further replies.

maverickmonster

Programmer
May 25, 2004
194
GB

Everytime I run this code on sheet3 i get a type mismatch and i dont know why ?

Sub count()
Dim date1 As String
Dim salary As String

n = 2149
start_row = 9


calc_row = start_row - 1

For Row_in = 1 To n
counter = 0
For i = 91 To 6 Step -4
date1 = Sheets(3).Cells(Row_in + calc_row, i - 1).Value
salary = Sheets(3).Cells(Row_in + calc_row, i).Value

'check if blank

If Len(date1) <> 0 Then
counter = counter + 1
If counter = 6 Then
counter = 0
'bomb to next line
GoTo continue_next
End If
cnt = counter
'need to print out last 5 entries
Sheets(3).Cells(Row_in + calc_row, 93 + (cnt * 2)).Value = date1
Sheets(3).Cells(Row_in + calc_row, 93 + (cnt * 2) + 1).Value = salary
End If


Next i
continue_next:
Next Row_in
End Sub
 
What happens if you replace this :
GoTo continue_next
By this ?
Exit For

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I still get a type mismatch ? on the same lines

date1 = Sheets(3).Cells(Row_in + calc_row, i - 1).Value
salary = Sheets(3).Cells(Row_in + calc_row, i).Value
 

Hello,

Is the value being stored in date1 a date? If so, try replacing:

Dim date1 As String

With:

Dim date1 As Date

- DCD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top