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

I'm getting a runtime error '13':
Type Mismatch

The code is:

Function UsageLog_1()

' Stores who and when on Sheet1, column C
Sheets("UsageLog").Select

If Range("C5600").End(xlUp).Row = 1 And Range("C5600").End(xlUp).Value =
"" Then <===== This is the line which is highlighted for the error
Range("C5600").End(xlUp).Value = "Last opened by " &
Environ("username") & " at " & Now
Exit Function
End If

Range("C5600").End(xlUp).Offset(1, 0).Value = "Last opened by " &
Environ("username") & " at " & Now

ThisWorkbook.Sheets("COVER").Activate
End Function

Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Runtime Error

What's in cell C1? I also get a type mismatch if I've got #N/A in C1, for
instance. If it's blank or alphanumeric, this seems okay.

"CurtH" wrote:

I'm getting a runtime error '13':
Type Mismatch

The code is:

Function UsageLog_1()

' Stores who and when on Sheet1, column C
Sheets("UsageLog").Select

If Range("C5600").End(xlUp).Row = 1 And Range("C5600").End(xlUp).Value =
"" Then <===== This is the line which is highlighted for the error
Range("C5600").End(xlUp).Value = "Last opened by " &
Environ("username") & " at " & Now
Exit Function
End If

Range("C5600").End(xlUp).Offset(1, 0).Value = "Last opened by " &
Environ("username") & " at " & Now

ThisWorkbook.Sheets("COVER").Activate
End Function

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Runtime Error

C1 is filled with: Last opened by chasan at 12/27/2005 3:43:08 PM

The log is suppose to annotate who accesses the files upon exiting the file.
So, the log move to the next blank line and enters the data.

"CurtH" wrote:

I'm getting a runtime error '13':
Type Mismatch

The code is:

Function UsageLog_1()

' Stores who and when on Sheet1, column C
Sheets("UsageLog").Select

If Range("C5600").End(xlUp).Row = 1 And Range("C5600").End(xlUp).Value =
"" Then <===== This is the line which is highlighted for the error
Range("C5600").End(xlUp).Value = "Last opened by " &
Environ("username") & " at " & Now
Exit Function
End If

Range("C5600").End(xlUp).Offset(1, 0).Value = "Last opened by " &
Environ("username") & " at " & Now

ThisWorkbook.Sheets("COVER").Activate
End Function

Thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Runtime Error

When the error occurs, what row has been selected by the end(xlUp)? In the
immediate window, what is the result of print range("c5600").End(xlUp).Row?
And what is in column C of that row? Even if the first condition of the AND
fails, Excel likes to evaluate the second condition, so an error in that cell
would also cause problems.


"CurtH" wrote:

I'm getting a runtime error '13':
Type Mismatch

The code is:

Function UsageLog_1()

' Stores who and when on Sheet1, column C
Sheets("UsageLog").Select

If Range("C5600").End(xlUp).Row = 1 And Range("C5600").End(xlUp).Value =
"" Then <===== This is the line which is highlighted for the error
Range("C5600").End(xlUp).Value = "Last opened by " &
Environ("username") & " at " & Now
Exit Function
End If

Range("C5600").End(xlUp).Offset(1, 0).Value = "Last opened by " &
Environ("username") & " at " & Now

ThisWorkbook.Sheets("COVER").Activate
End Function

Thanks in advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Runtime Error

Thanks! You got me to think and figured it out.

"bpeltzer" wrote:

When the error occurs, what row has been selected by the end(xlUp)? In the
immediate window, what is the result of print range("c5600").End(xlUp).Row?
And what is in column C of that row? Even if the first condition of the AND
fails, Excel likes to evaluate the second condition, so an error in that cell
would also cause problems.


"CurtH" wrote:

I'm getting a runtime error '13':
Type Mismatch

The code is:

Function UsageLog_1()

' Stores who and when on Sheet1, column C
Sheets("UsageLog").Select

If Range("C5600").End(xlUp).Row = 1 And Range("C5600").End(xlUp).Value =
"" Then <===== This is the line which is highlighted for the error
Range("C5600").End(xlUp).Value = "Last opened by " &
Environ("username") & " at " & Now
Exit Function
End If

Range("C5600").End(xlUp).Offset(1, 0).Value = "Last opened by " &
Environ("username") & " at " & Now

ThisWorkbook.Sheets("COVER").Activate
End Function

Thanks in advance

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
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
naming tab macro error runtime error 1004 D Excel Programming 3 February 28th 05 01:32 AM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 10:29 PM.

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"