ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Type Mismatch (https://www.excelbanter.com/excel-programming/358866-type-mismatch.html)

Abode

Type Mismatch
 
Hello. I am having a little problem with this code. Under ideal conditions
it does seem to work just fine. I've found that it seems to bug out when it
reaches a Cell (which the value is to be put in the "Entry" Object) that
happens to be blank. Now as far as I know that shouldn't cause a problem.
The really strange thing is that is gives a "Type Mismatch" error. I figured
It might have a space in there which when I click on the cell and use the
arrow keys to move the cursor through any spaces it doesn't move. I press
delete over the cells and it gets past that one line. So something is in
there but nothing I can find. Is there a way I can get it to pass over these
Not so blank Cells. Or maybe its just a problem with my code. Thank you for
your time. (part of the code is below incase you want a look through it.
The problem areas seem to be in the If statements with the < "" in them)

Mark



RowNum = 1
Do While (Worksheets("GL Hazard Schedule").Range("B" & RowNum).Value < "")
Or _
(Worksheets("GL Hazard Schedule").Range("B" & RowNum + 1).Value <
"")
RowNum = RowNum + 1
Loop
RowNum = RowNum - 1

Set MyRange = Worksheets("GL Hazard Schedule").Range("A3:AI" & RowNum)
RowNum = RowNum - 2

For i = 1 To RowNum
Quotes = 0
MsgBox "fsdfs"
Set Entry = MyCol(MyRange.Range("B" & i))
Do While MyRange.Range("B" & i).Value < ""
Entry.Zip = MyRange.Range("F" & i).Value
If MyRange.Range("U" & i).Value < "" Then
Entry.GlLoc = MyRange.Range("Y" & i).Value
Entry.GlHaz = Quotes
If MyRange.Range("AB" & i).Value < "" Then
Entry.ClassCode = MyRange.Range("AB" & i).Value
End If
If MyRange.Range("AH" & i).Value < "" Then
Entry.GlPremium = MyRange.Range("AH" & i).Value
End If
If MyRange.Range("AI" & i).Value < "" Then
Entry.GlPremium = MyRange.Range("AI" & i).Value
End If
End If
Quotes = Quotes + 1
i = i + Quotes
Loop
'MyCol.Add Item:=Entry, Key:=Entry.QuoteID
Next i

Abode

Type Mismatch
 
Nevermind! Im ticked off. I needed to get Values from Column Y and Z. Not
U and Y. U Stored a a string where it was trying to be put into an Integer.
I spent around five or six hours trying to figure out the problem and
deleting every blank I could.

"Abode" wrote:

Hello. I am having a little problem with this code. Under ideal conditions
it does seem to work just fine. I've found that it seems to bug out when it
reaches a Cell (which the value is to be put in the "Entry" Object) that
happens to be blank. Now as far as I know that shouldn't cause a problem.
The really strange thing is that is gives a "Type Mismatch" error. I figured
It might have a space in there which when I click on the cell and use the
arrow keys to move the cursor through any spaces it doesn't move. I press
delete over the cells and it gets past that one line. So something is in
there but nothing I can find. Is there a way I can get it to pass over these
Not so blank Cells. Or maybe its just a problem with my code. Thank you for
your time. (part of the code is below incase you want a look through it.
The problem areas seem to be in the If statements with the < "" in them)

Mark



RowNum = 1
Do While (Worksheets("GL Hazard Schedule").Range("B" & RowNum).Value < "")
Or _
(Worksheets("GL Hazard Schedule").Range("B" & RowNum + 1).Value <
"")
RowNum = RowNum + 1
Loop
RowNum = RowNum - 1

Set MyRange = Worksheets("GL Hazard Schedule").Range("A3:AI" & RowNum)
RowNum = RowNum - 2

For i = 1 To RowNum
Quotes = 0
MsgBox "fsdfs"
Set Entry = MyCol(MyRange.Range("B" & i))
Do While MyRange.Range("B" & i).Value < ""
Entry.Zip = MyRange.Range("F" & i).Value
If MyRange.Range("U" & i).Value < "" Then
Entry.GlLoc = MyRange.Range("Y" & i).Value
Entry.GlHaz = Quotes
If MyRange.Range("AB" & i).Value < "" Then
Entry.ClassCode = MyRange.Range("AB" & i).Value
End If
If MyRange.Range("AH" & i).Value < "" Then
Entry.GlPremium = MyRange.Range("AH" & i).Value
End If
If MyRange.Range("AI" & i).Value < "" Then
Entry.GlPremium = MyRange.Range("AI" & i).Value
End If
End If
Quotes = Quotes + 1
i = i + Quotes
Loop
'MyCol.Add Item:=Entry, Key:=Entry.QuoteID
Next i



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com