# Quick Excel macro question

**URL:** <https://boards.straightdope.com/t/quick-excel-macro-question/432129>\
**Category:** Factual Questions\
**Created:** [January 3, 2008, 3:05pm UTC](https://boards.straightdope.com/t/quick-excel-macro-question/432129 "2008-01-03T15:05:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roland\_Orzabal](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Roland\_Orzabal](https://boards.straightdope.com/u/Roland_Orzabal)\
**Post date:** [January 3, 2008, 3:05pm UTC](https://boards.straightdope.com/t/quick-excel-macro-question/432129/1 "2008-01-03T15:05:19Z")

</div>

This is, in all likelihood, a stupid question, but…in an VB6 macro for Excel 2003, why does the following code return a type mismatch error if the cell (E, ActiveCell.row) is formatted as “Date (m/d/yy)”, and contains the data “10/2/2006” (without the quotes)?

```auto

Dim EnrollDate as Date

EnrollDate = Cells("E", ActiveCell.row).Value

```

I have also tried using “EnrollDate = Cells(“E”, ActiveCell.row).Text”, but that returns a type mismatch as well.

I’ve never had a problem getting VB to accept dates in this format before, so I figure I’m doing something wrong with my assignment statement (I don’t usually work in Excel). Can anyone help me out?

ETA: I also tried formatting the cell as plain text rather than a date. That didn’t work either.

---

<div class="post-metadata">

**Author:** ![Roland\_Orzabal](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@Roland\_Orzabal](https://boards.straightdope.com/u/Roland_Orzabal)\
**Post date:** [January 3, 2008, 3:12pm UTC](https://boards.straightdope.com/t/quick-excel-macro-question/432129/2 "2008-01-03T15:12:35Z")

</div>

I KNEW this would happen as soon as I posted the thread…

Never mind, answered my own question. Apparently the proper assignment is Cells(row, column), which is completely ass-backwards if you ask me, but there you have it. Mods, feel free to lock this thread if you wish.
