PC Review


Reply
Thread Tools Rate Thread

how to assign contents of a cell to a macro variable

 
 
=?Utf-8?B?RGF2aWRI?=
Guest
Posts: n/a
 
      20th Aug 2007
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



 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      20th Aug 2007
either:
CellDesc = ActiveWorkbook.Sheets("General Documentation").Cells("a6").Value
(Notice the "A6" change.)

or

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



DavidH wrote:
>
> 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


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      20th Aug 2007
David,

Try:

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

--
Hope that helps.

Vergel Adriano


"DavidH" wrote:

> 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
>
>
>

 
Reply With Quote
 
=?Utf-8?B?RGF2aWRI?=
Guest
Posts: n/a
 
      20th Aug 2007
Thanks Vergel, it worked perfectly!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
assign next serial number based on contents of another cell clint Microsoft Excel New Users 2 26th Aug 2009 01:57 AM
Assign a value to a variable by next selected cell? Brad Microsoft Excel Programming 3 22nd Jul 2008 09:00 PM
How do I assign the value in a cell to a variable? JasonK Microsoft Excel Discussion 7 7th Jun 2006 11:17 PM
Assign cell value to variable =?Utf-8?B?Um9va2llX1VzZXI=?= Microsoft Excel Programming 2 7th Jun 2006 08:15 PM
how do i assign the contents of a cell to a range name =?Utf-8?B?dGVuc3dn?= Microsoft Excel Worksheet Functions 1 24th Aug 2004 01:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:46 PM.