ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dim c as Cell (https://www.excelbanter.com/excel-programming/425886-dim-c-cell.html)

Keith Howard

Dim c as Cell
 
Hello.

I have an embarrassingly simple question. How do I declare a variable as a
Cell? The above line is not compiling.

I have set the following Tools | References:
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library

I'm sure I have done this many times in the past successfully, but, for some
reason, it is not working now.

Thanks.

Keith

Legare

Dim c as Cell
 
Try:

DIM C As Range

A cell is a range containing only one cell.

"Keith Howard" wrote:

Hello.

I have an embarrassingly simple question. How do I declare a variable as a
Cell? The above line is not compiling.

I have set the following Tools | References:
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library

I'm sure I have done this many times in the past successfully, but, for some
reason, it is not working now.

Thanks.

Keith


JLGWhiz[_2_]

Dim c as Cell
 
Cell is not a valid object class. You declare a cell as a Range.

Dim c As Range


"Keith Howard" wrote in message
...
Hello.

I have an embarrassingly simple question. How do I declare a variable as a
Cell? The above line is not compiling.

I have set the following Tools | References:
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library

I'm sure I have done this many times in the past successfully, but, for
some
reason, it is not working now.

Thanks.

Keith




[email protected]

Dim c as Cell
 
On Mar 21, 12:52*pm, Keith Howard
wrote:
Hello.

I have an embarrassingly simple question. How do I declare a variable as a
Cell? The above line is not compiling.

I have set the following Tools | References:
Visual Basic For Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library

I'm sure I have done this many times in the past successfully, but, for some
reason, it is not working now.

Thanks.

Keith


Keith,

I'm using Excel 2003, but the only way I know how to dimension a
variable as a "cell" is to dimension the variable as a range.

Dim rngMyCell As Range
Set rngMyCell = Range("A1")

You now have a range object (rngMyCell) which you can manipulate.

Best,

Matt Herbert


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com