Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
using windows XP; created macro to look at each cell in a one column range.
named range. dim. variables. selected worksheet.selected named range. created for next cell in seledction. see following Sheets("Sheet2").Select Range("I16.I45").Select For Each cell In Selection If ActiveCell.Value = False Then ActiveCell.Offset(0, -2).Value = ActiveCell.Offset(0, -2).Value + Range("step").Value End If Next cell the offset value is increased until the active cell is not false but the program does not loop to the next cell in the range. how do i correct? -- stub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A For Each loop does NOT change what cell is active. As it loops, it sets
the control variable ("cell" in your example code) to each cell in the given range, but unless you explicitly activate the cell, the ActiveCell remains what it was prior to the loop. Instead of ActiveCell.Value use Cell.Value or activate cell: Cell.Activate -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "stub" wrote in message ... using windows XP; created macro to look at each cell in a one column range. named range. dim. variables. selected worksheet.selected named range. created for next cell in seledction. see following Sheets("Sheet2").Select Range("I16.I45").Select For Each cell In Selection If ActiveCell.Value = False Then ActiveCell.Offset(0, -2).Value = ActiveCell.Offset(0, -2).Value + Range("step").Value End If Next cell the offset value is increased until the active cell is not false but the program does not loop to the next cell in the range. how do i correct? -- stub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
just insert:
cell.Activate after the For statement -- Gary''s Student - gsnu200760 "stub" wrote: using windows XP; created macro to look at each cell in a one column range. named range. dim. variables. selected worksheet.selected named range. created for next cell in seledction. see following Sheets("Sheet2").Select Range("I16.I45").Select For Each cell In Selection If ActiveCell.Value = False Then ActiveCell.Offset(0, -2).Value = ActiveCell.Offset(0, -2).Value + Range("step").Value End If Next cell the offset value is increased until the active cell is not false but the program does not loop to the next cell in the range. how do i correct? -- stub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Step through cells in a selected range | Excel Programming | |||
Step through cells in a selected range | Excel Programming | |||
Set Range Using Selected Cells | Excel Programming | |||
Compare a selected Range with a Named range and select cells that do not exist | Excel Programming | |||
max/min of a selected range of cells | Excel Programming |