range problem

  • Thread starter Thread starter PeterS
  • Start date Start date
P

PeterS

For iColCnt = 1 To 49
'reset to startingcell
Call UtilitiesQuickSelectStartCell("Numbers", "DrawsTableStart")
'loop through columns
Call RangeTableActiveCellToSpecificRow(iDrawsToUse, 1, 1, iColCnt)
On Error Resume Next
I am trying to loop through a series of columns. I select a range of
cells within each column, if the cells have numbers in them. I find
that when a column has no cells with numeric values the range of cells
from teh previous column is being used. Could someone tell me how to
prevent thios?

thianks

For iColCnt = 1 To 100
'select the cells with numbers
Set rngCellsWithData = Selection.SpecialCells(xlConstants,
xlNumbers)
iTest = rngCellsWithData.SpecialCells(xlConstants,
xlNumbers).Count
If (rngCellsWithData.SpecialCells(xlConstants, xlNumbers).Count >
0) Then
'process the cells
End If
Next
 
Try setting the range variable rngCellsWithData to Nothing after processing.
You can also test if for nothing to see if there is anything to process.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Object range failed 1
Ranges 2
Add subtotal formula to empty cells 4
Error code 91 7
Speed Up this Macro? Part 2 6
Strange Range Behavior 2
Speed Up this macro? 22
VBA Loop Problem 2

Back
Top