View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default activecell giving me a hard time

How are you using the ActiveCell.Offset() to move from column to column? I
mean by that, are you doing this...

ActiveCell.Offset(,1).Select

If so, don't... just increment the offset amount without doing the
selection. If you do it that way, then the ActiveCell will not have moved
and then this...

ActiveCell.Offset(1).Select

will work as you expect. However, I wouldn't even do it that way. I would
simply use a double loop to move column to column and then row to row.
Something like this...

ActiveCell.Offset(RowOffset, ColOffset)

either Set'ting it equal to a range variable to be used within the loop or
directly specifying the property to reference (it kind of depends on what
you are actually doing to the cells you visit which method to use).

--
Rick (MVP - Excel)


"LetMeDoIt" wrote in message
...
Greetings,

I'm using office 2003 in Excel VBA. ActiveCell.Offset() is used to
write to various cells, moving along columns, in another sheet, ie.
write to cell B1, then C1, then D1, etc. This works well.

The problem I have is I then try to set the active cell to the next
row on column A, but get an error msg. I do not want to using
ActiveCell.Offset() cause I do not know how many columns I wrote to (I
could find out, but that defeats the purpose of understanding the
issue).

I tried various statements, all giving me an error msg:

Range("'" & sheetName & "'!B1").Value = "NEW VALUE HERE" or
Range("A1").Value = "NEW VALUE HERE"

This does not give me an error msg, but jumps 6 rows down from where
the current active cell is:
ActiveCell.Range("A6").Select

Any help is greatly appreciated...
CG