how to assign contents of a cell to a macro variable

D

DavidH

Hi,

I'm trying to set the contents of cell A6 in the "General Documentation"
worksheet of the active workbook to a variable. First I test for the General
Documentation worksheet, and that part of my code works. Here's the next part:

Dim CellDesc As String
CellDesc = ActiveWorkbook.Sheets("General Documentation").Cells(a6).Value

I get error 1004, application defined or object defined error. Should I be
using something else besides string? Does it make a difference if the cell
value is a string or a number?

Thanks for the help!

David
 
D

Dave Peterson

either:
CellDesc = ActiveWorkbook.Sheets("General Documentation").Cells("a6").Value
(Notice the "A6" change.)

or

CellDesc = ActiveWorkbook.Sheets("General Documentation").Cells(6,"A").Value
 
V

Vergel Adriano

David,

Try:

CellDesc = ActiveWorkbook.Sheets("General Documentation").Range("A6").Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top