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

Below is the code I am trying to use, but I keep getting a type mismatch
(Runtime Error 13) on the line indicated with "ERROR". The value I am
pulling into date2 is formatted as DATE within the spreadsheet.

What do I need to change?

'Display Estimated Pay on Part-time jobs for current payperiod
Private Sub CommandButton6_Click()
Dim date2, date3 As Date
Dim k, startrow, endrow, gotbrs As Integer
Dim brs, pas As Variant
Dim rng As Range
date3 = Date
Set rng = Worksheets("PT").Range("J8:J58")
startrow = 8
endrow = 58
Loop1:
For k = startrow To endrow Step 2
date2 = rng.Offset(0, 0).Value <=====ERROR
'MsgBox date2
If date3 <= date2 Then
If endrow <= 58 Then
brs = rng.Offset(k - 1, 3).Value
k = endrow
gotbrs = 1
startrow = 67
endrow = 117
rng = Range("J67:J117")
Else
pas = rng.Offset(k - 1, 3).Value
Set k = endrow
End If
End If
Next k
If gotbrs = 1 Then
gotbrs = 0
GoTo Loop1
End If
MsgBox "BRS: " & " brs" & " PAS: " & pas & " TOTAL: " & (brs + pas)
End Sub

Thanks,
Les
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Type Mismatch

I was able to fix the problem via trial and error. Thanks anyway.

Les

"WLMPilot" wrote:

Below is the code I am trying to use, but I keep getting a type mismatch
(Runtime Error 13) on the line indicated with "ERROR". The value I am
pulling into date2 is formatted as DATE within the spreadsheet.

What do I need to change?

'Display Estimated Pay on Part-time jobs for current payperiod
Private Sub CommandButton6_Click()
Dim date2, date3 As Date
Dim k, startrow, endrow, gotbrs As Integer
Dim brs, pas As Variant
Dim rng As Range
date3 = Date
Set rng = Worksheets("PT").Range("J8:J58")
startrow = 8
endrow = 58
Loop1:
For k = startrow To endrow Step 2
date2 = rng.Offset(0, 0).Value <=====ERROR
'MsgBox date2
If date3 <= date2 Then
If endrow <= 58 Then
brs = rng.Offset(k - 1, 3).Value
k = endrow
gotbrs = 1
startrow = 67
endrow = 117
rng = Range("J67:J117")
Else
pas = rng.Offset(k - 1, 3).Value
Set k = endrow
End If
End If
Next k
If gotbrs = 1 Then
gotbrs = 0
GoTo Loop1
End If
MsgBox "BRS: " & " brs" & " PAS: " & pas & " TOTAL: " & (brs + pas)
End Sub

Thanks,
Les

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Type Mismatch

Well, I will lay out the chart for you and see what you come up with. Chart
is simply a spreadsheet, not a true CHART that is a diagram based on data.

General Description: Chart is 52 rows (ie 52 weeks) divided into two week
payperiods. Payday (date) starts in J8 and increase by 14 days every two
rows, ie J10 = J8+14, J12 = J10+14, etc. I have two charts, one for each
parttime job, therefore you will notice the startrow & endrow numbers change.


Basically, I click a command button that will execute the code to find the
pay for each job and display it along with a total.

Payday (date) range:
Job1 = J8:J58 (every other row)
Job2 = J67:J117 (every other row)

I have place the current code that works below, which is a little different
from first code I posted.

'Display Estimated Pay on Part-time jobs for current payperiod
Private Sub CommandButton6_Click()
Dim date2, date3 As Date
Dim k, startrow, endrow, gotbrs, ans As Integer
Dim brs, pas As Single
Const sfmt As String = "$##0.00"
'Const dfmt As Date = "##/##/##"
Dim answer, brsdate, pasdate As String
date3 = Date
startrow = 8
endrow = 58
Loop1:
For k = startrow To endrow Step 2
date2 = Cells(k, 10).Value
If date3 <= date2 Then
If endrow <= 58 Then
brs = Cells(k - 1, 13).Value
brsdate = date2
MsgBox brsdate
k = endrow
gotbrs = 1
startrow = 67
endrow = 117
Else
pas = Cells(k - 1, 13).Value
pasdate = date2
MsgBox Len(pasdate)
k = endrow
End If
End If
Next k
If gotbrs = 1 Then
gotbrs = 0
GoTo Loop1
End If
answer = " Belton (" & FormatDateTime(brsdate, vbShortDate) &
"): " &
Format(brs, sfmt) & _
vbLf & " Palmetto (" & FormatDateTime(pasdate, vbShortDate) & "):
" &
Format(pas, sfmt) & _
vbLf & " Total: " & Format(brs + pas, sfmt)
ans = MsgBox(answer, vbOKOnly, "Current Payperiod - Estimated Pay")
End Sub

Thanks for your time is looking at this.

Les




"Don Guillett" wrote:

The point is that there might be a better way.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"WLMPilot" wrote in message
...
I was able to fix the problem via trial and error. Thanks anyway.

Les

"WLMPilot" wrote:

Below is the code I am trying to use, but I keep getting a type mismatch
(Runtime Error 13) on the line indicated with "ERROR". The value I am
pulling into date2 is formatted as DATE within the spreadsheet.

What do I need to change?

'Display Estimated Pay on Part-time jobs for current payperiod
Private Sub CommandButton6_Click()
Dim date2, date3 As Date
Dim k, startrow, endrow, gotbrs As Integer
Dim brs, pas As Variant
Dim rng As Range
date3 = Date
Set rng = Worksheets("PT").Range("J8:J58")
startrow = 8
endrow = 58
Loop1:
For k = startrow To endrow Step 2
date2 = rng.Offset(0, 0).Value <=====ERROR
'MsgBox date2
If date3 <= date2 Then
If endrow <= 58 Then
brs = rng.Offset(k - 1, 3).Value
k = endrow
gotbrs = 1
startrow = 67
endrow = 117
rng = Range("J67:J117")
Else
pas = rng.Offset(k - 1, 3).Value
Set k = endrow
End If
End If
Next k
If gotbrs = 1 Then
gotbrs = 0
GoTo Loop1
End If
MsgBox "BRS: " & " brs" & " PAS: " & pas & " TOTAL: " & (brs +
pas)
End Sub

Thanks,
Les





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: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
13 type mismatch help Mike K Excel Programming 2 June 23rd 05 02:51 AM
Type mismatch? John Wirt[_9_] Excel Programming 6 December 11th 04 09:37 PM


All times are GMT +1. The time now is 05:09 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"