Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

excel cell value

0 views
Skip to first unread message

jnewl

unread,
Nov 14, 2007, 3:18:00 PM11/14/07
to
want to check for a specific value in col 1 and row 1. if that value is not
there, will cancel the operation.

how do i check for that value?

tried this

xlsheet.cells("1:1") = rowvalue

If rowvalue = "code" Then
GoTo contin
Else
GoTo Err_addl_update_Click
End If
contin:

rowvalue is defined as a string

get error msg that not valid construct

thanks for your help

John W. Vinson

unread,
Nov 14, 2007, 4:53:28 PM11/14/07
to
On Wed, 14 Nov 2007 12:18:00 -0800, jnewl <jn...@discussions.microsoft.com>
wrote:

Aren't Excel cells indexed by letters in the columns, not numbers? Try "A:1".

If you're running this code in Excel, please post your questions in an Excel
newsgroup.

John W. Vinson [MVP]

jnewl

unread,
Nov 14, 2007, 5:50:01 PM11/14/07
to
that did not work

i have done something like this because i had to insert a row
xlsheet.rows("1:1").Insert
xlsheet.cells(1, 1) = "aaaa"

therefore i thought i could do
if xlsheet.rows ("1:1").value = "code" then
do stuff

John W. Vinson

unread,
Nov 14, 2007, 7:20:03 PM11/14/07
to
On Wed, 14 Nov 2007 14:50:01 -0800, jnewl <jn...@discussions.microsoft.com>
wrote:

>that did not work
>
>i have done something like this because i had to insert a row
>xlsheet.rows("1:1").Insert
>xlsheet.cells(1, 1) = "aaaa"
>
>therefore i thought i could do
> if xlsheet.rows ("1:1").value = "code" then
> do stuff
>

I'd ask in an Excel newsgroup, or repost under a new header - this is Excel
syntax with which I am not familiar.

John W. Vinson [MVP]

John Nurick

unread,
Nov 15, 2007, 2:00:26 AM11/15/07
to
If you've already created an Excel worksheet object you can get the
value of cell A1 with
xlsheet.Cells(1,1).Value 'row 1, column 1
or
xlsheet.Range("A1").Value

To save launching Excel, you can do it like this (watch out for line
wrapping in the Set R... statement:

Dim R As DAO.Recordset

Set R = CurrentDB.OpenRecordset("SELECT F1 FROM [Excel8.0;" _
& "HDR=No;database=C:\folder\XXX.xls;].[Sheet1$A1:A1];")

'The value you want is now in R.Fields(0).Value
...
R.Close


On Wed, 14 Nov 2007 12:18:00 -0800, jnewl
<jn...@discussions.microsoft.com> wrote:

--
John Nurick - Access MVP

0 new messages