![]() |
how to recycle through cells in a selected range
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 |
how to recycle through cells in a selected range
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 |
how to recycle through cells in a selected range
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 |
All times are GMT +1. The time now is 06:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com