ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activecell Offset (https://www.excelbanter.com/excel-programming/318452-activecell-offset.html)

Mark

Activecell Offset
 
I am using Excel 97.

I have some code which finds an empty row and then populates cells in the
13th column for the previous 7 rows.
Using activecell.offset(-7,13)

My code debugs when there aren't 7 rows before the empty row!

Can someone assist me with some code which checks to see if there are 7 rows
before the empty row and if not moves to the next sheet.


----
Mark

Sharad Naik[_3_]

Activecell Offset
 

Hi,
You can simply use ActiveCell.Row which will return the row number of
the active cell. If it is greater than 7 you have atleast 7 rows up.

If ActiveCell.Row 7 Then

.... your code.


Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

gocush[_28_]

Activecell Offset
 
Or if you are not selecting cells and just have a variable assigned to the
first cell in your newly found empty row (such as rCell), then use

if rCell.row7 then
'your code
end if

"Mark" wrote:

I am using Excel 97.

I have some code which finds an empty row and then populates cells in the
13th column for the previous 7 rows.
Using activecell.offset(-7,13)

My code debugs when there aren't 7 rows before the empty row!

Can someone assist me with some code which checks to see if there are 7 rows
before the empty row and if not moves to the next sheet.


----
Mark



All times are GMT +1. The time now is 01:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com