Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Type mismatch problem

I have a date in both B1 and B2 (sheet "Macro Data"). In my macro, I have the
following code:

Dim EndDate As Date
Dim StartDate As Date

StartDate = Sheets("Macro Data").Cells("B1")
EndDate = Sheets("Macro Data").Cells("B2")

The above statements are giving me error 13 (type mismatch). What's wrong
with my statements? How do I reference the date data in my macro? Thanks!

Dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch problem


Instead of:
StartDate = Sheets("Macro Data").Cells("B1")

Try:
StartDate = Sheets("Macro Data").Cells("B1").Value


--
C01d
------------------------------------------------------------------------
C01d's Profile: http://www.excelforum.com/member.php...o&userid=34422
View this thread: http://www.excelforum.com/showthread...hreadid=546956

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Type mismatch problem


Dan wrote:
My English is very bad. I hope you can understand what I say .

The type of "CellS()" is wrong. The Correct is "Cells(row,column)"

StartDate = Sheets("Macro Data").Cells(2,1)
EndDate = Sheets("Macro Data").Cells(2,2)

or you can use

StartDate = Sheets("Macro Data").Range("B1")
EndDate = Sheets("Macro Data").Range("B2")

Aheng
MSN:

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Type mismatch problem


wrote:

Sorry, The previous has some wrong,


The correct is
StartDate = Sheets("Macro Data").Cells(1,2)


Aheng
MSN:


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Type mismatch problem

You can also do sheets("Macro Data").range("A2")
wrote:
wrote:

Sorry, The previous has some wrong,


The correct is
StartDate = Sheets("Macro Data").Cells(1,2)


Aheng
MSN:




  #6   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Type mismatch problem

When I use

StartDate = Sheets("Macro Data").Range("B1").Value

it works. If I use

StartDate = Sheets("Macro Data").Cells("B1").Value

I get the type mismatch error. This is my first attempt to use macros in
Excel. What is the difference between Range and Cells?

Dan


" wrote:

You can also do sheets("Macro Data").range("A2")
wrote:
wrote:

Sorry, The previous has some wrong,


The correct is
StartDate = Sheets("Macro Data").Cells(1,2)


Aheng
MSN:



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Type mismatch problem

Cells requires the row/col co-ordinates - see the examples above, range
will allow a text string
Dan wrote:
When I use

StartDate = Sheets("Macro Data").Range("B1").Value

it works. If I use

StartDate = Sheets("Macro Data").Cells("B1").Value

I get the type mismatch error. This is my first attempt to use macros in
Excel. What is the difference between Range and Cells?

Dan


" wrote:

You can also do sheets("Macro Data").range("A2")
wrote:
wrote:

Sorry, The previous has some wrong,

The correct is
StartDate = Sheets("Macro Data").Cells(1,2)


Aheng
MSN:




  #8   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Type mismatch problem

Okay. That's helpful. Thanks!

Dan

" wrote:

Cells requires the row/col co-ordinates - see the examples above, range
will allow a text string
Dan wrote:
When I use

StartDate = Sheets("Macro Data").Range("B1").Value

it works. If I use

StartDate = Sheets("Macro Data").Cells("B1").Value

I get the type mismatch error. This is my first attempt to use macros in
Excel. What is the difference between Range and Cells?

Dan


" wrote:

You can also do sheets("Macro Data").range("A2")
wrote:
wrote:

Sorry, The previous has some wrong,

The correct is
StartDate = Sheets("Macro Data").Cells(1,2)


Aheng
MSN:





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 problem in array - ?? ina Excel Programming 6 May 17th 06 12:56 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Type mismatch error problem when dealing with Strings David Goodall[_2_] Excel Programming 4 June 30th 05 01:40 PM
Type Mismatch Problem Damien McBain[_2_] Excel Programming 2 May 20th 05 04:09 PM
Type mismatch problem? NooK[_45_] Excel Programming 3 August 4th 04 01:07 PM


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