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

Okay so I'm a little rusty on my Excel VBA skills and I can't figure
out why I'm getting a type mismatch error for the following line in my
code:

Dim CopyEventDateCell As Date
Dim MyRow as integer
MyRow = 2

CopyEventDateCell = Workbooks("IT Operations Summarized Change
Report TEST.xls").Worksheets("IT Operations").Cells(MyRow, 6).Value

The only thing I can think of is it's an issue with the date format?
The cell value I'm referencing is in date format...I'm baffled, help!!!

Thanks,
Shelley

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Type Mismatch!!!

I just figured it out...I need to dim copyeventdatecell as variant,
duh!!!

Sorry if I wasted anyone's time...

Shelley

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Type Mismatch!!!

Perhaps a little testing:

Dim CopyEventDateCell As Date
Dim MyRow as Long
Dim rng as Range
MyRow = 2

set rng = Workbooks("IT Operations Summarized Change
Report TEST.xls").Worksheets("IT Operations").Cells(MyRow, 6)

msgbox typename(rng.value) & ", " & isdate(rng.value)

--
Regards,
Tom Ogilvy

"sbowman" wrote:

Okay so I'm a little rusty on my Excel VBA skills and I can't figure
out why I'm getting a type mismatch error for the following line in my
code:

Dim CopyEventDateCell As Date
Dim MyRow as integer
MyRow = 2

CopyEventDateCell = Workbooks("IT Operations Summarized Change
Report TEST.xls").Worksheets("IT Operations").Cells(MyRow, 6).Value

The only thing I can think of is it's an issue with the date format?
The cell value I'm referencing is in date format...I'm baffled, help!!!

Thanks,
Shelley


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Type Mismatch!!!

You shouldn't have to if the cell contains a date.

As a demonstration, this works fine for me:

Sub tester1()
Dim dt As Date
ActiveCell.Value = Date
dt = ActiveCell.Value
MsgBox dt
End Sub

--
Regards,
Tom Ogilvy


"sbowman" wrote:

I just figured it out...I need to dim copyeventdatecell as variant,
duh!!!

Sorry if I wasted anyone's time...

Shelley


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

Darn it, using variant doesn't work for me because i have to do
comparisons later on in the code (less than, equal to, etc.). The cells
I'm referencing are formatted as dates but some of them do have some
text in them which may be throwing off my code. I really need to dim as
date, help!!!

Shelley



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Type Mismatch!!!

formatting has no effect on what is stored in the cell. It appears you have
a text string stored in the cell. You will have to parse out the date
portion and convert it to a date if you need a date serial number.

--
Regards,
Tom Ogilvy


"sbowman" wrote:

Darn it, using variant doesn't work for me because i have to do
comparisons later on in the code (less than, equal to, etc.). The cells
I'm referencing are formatted as dates but some of them do have some
text in them which may be throwing off my code. I really need to dim as
date, help!!!

Shelley


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Type Mismatch!!!

How can I parse the date out of the field? It's completely random, some
people put in a description with the date, others put in just the date,
etc. The way people enter this data into the spreadsheet will not
change, I'm creating a workaround to generate a report. I'm going to be
creating an Access application for this mess in the future :-)

Shelley

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
type mismatch Donnie Fuqua Excel Programming 2 June 28th 05 03:29 AM
Type Mismatch Rockee052[_60_] Excel Programming 4 March 7th 04 12:12 AM


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