PC Review


Reply
Thread Tools Rate Thread

Using Excel "Cells" function in Access Module

 
 
Dkline
Guest
Posts: n/a
 
      25th Jun 2004
My database is using Excel as its calculation engine. When returning a
calculated value to the recordset, I have to get the value from a cell based
on input e.g. return the value from year 5, month 1.

Basically the row in the spreadsheet from which I am to get the value
changes based on the user input. In Excel I would normally use the
Cells(RowIndex, ColumnIndex) function.

My code is
intRowValue = intRowOffset + ((intYear - 1) * 12) + intMonth
'example - year 2, month 1 is in row 20 on the worksheet
rec("xlCOI").Value = objWSVL.Range(Cells(intRowValue, 12)).Value

If I use the above I get this error "<Method 'Cells' of object '_Global'
failed>

If I use just Range it works fine e.g. rec("xlCOI").Value =
objWSVL.Range("L57")).Value

Does this mean I can't use Cells?


 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      25th Jun 2004
You need to qualify the Cells with the worksheet object too.

rec("xlCOI").Value = objWSVL.Range(objWSVL.Cells(intRowValue, 12)).Value

--

Ken Snell
<MS ACCESS MVP>

"Dkline" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> My database is using Excel as its calculation engine. When returning a
> calculated value to the recordset, I have to get the value from a cell

based
> on input e.g. return the value from year 5, month 1.
>
> Basically the row in the spreadsheet from which I am to get the value
> changes based on the user input. In Excel I would normally use the
> Cells(RowIndex, ColumnIndex) function.
>
> My code is
> intRowValue = intRowOffset + ((intYear - 1) * 12) + intMonth
> 'example - year 2, month 1 is in row 20 on the worksheet
> rec("xlCOI").Value = objWSVL.Range(Cells(intRowValue, 12)).Value
>
> If I use the above I get this error "<Method 'Cells' of object '_Global'
> failed>
>
> If I use just Range it works fine e.g. rec("xlCOI").Value =
> objWSVL.Range("L57")).Value
>
> Does this mean I can't use Cells?
>
>



 
Reply With Quote
 
 
 
 
Dkline
Guest
Posts: n/a
 
      25th Jun 2004
That was the problem.

What I ended up with is:
rec("xlCOI").Value = objWSVL.Range(objWSVL.Cells(intRowValue, 12),
objWSVL.Cells(intRowValue, 12)).Value

You had to dilenate the range by specifing the range as Range(cell1, cell2).
It didn't work using just (cell1) - had to specifiy both and include the
object with each Cell(row,column).

Thanks for the help.


"Ken Snell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You need to qualify the Cells with the worksheet object too.
>
> rec("xlCOI").Value = objWSVL.Range(objWSVL.Cells(intRowValue, 12)).Value
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
> "Dkline" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > My database is using Excel as its calculation engine. When returning a
> > calculated value to the recordset, I have to get the value from a cell

> based
> > on input e.g. return the value from year 5, month 1.
> >
> > Basically the row in the spreadsheet from which I am to get the value
> > changes based on the user input. In Excel I would normally use the
> > Cells(RowIndex, ColumnIndex) function.
> >
> > My code is
> > intRowValue = intRowOffset + ((intYear - 1) * 12) + intMonth
> > 'example - year 2, month 1 is in row 20 on the worksheet
> > rec("xlCOI").Value = objWSVL.Range(Cells(intRowValue, 12)).Value
> >
> > If I use the above I get this error "<Method 'Cells' of object '_Global'
> > failed>
> >
> > If I use just Range it works fine e.g. rec("xlCOI").Value =
> > objWSVL.Range("L57")).Value
> >
> > Does this mean I can't use Cells?
> >
> >

>
>



 
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
In Excel vba how do you Launch code a standalone Module from a Form or other Module ? tmb Microsoft Excel Discussion 1 10th Apr 2005 11:40 PM
how to call Access function&module in Excel VBA?? =?Utf-8?B?bWlhbyBqaWU=?= Microsoft Excel Programming 1 24th Jul 2004 04:49 PM
Using an Excel Worksheet function in Access Module keith Microsoft Access VBA Modules 6 12th Mar 2004 10:01 PM
Problems with "Unknown function name" using Access module Jacob Hojnacki Microsoft Access VBA Modules 1 29th Oct 2003 05:39 PM
Split Database, Invoice Module and Payroll Module, (2) Instances of Access, Good,Bad ? Dave Elliott Microsoft Access Forms 0 25th Aug 2003 03:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 PM.