View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
cadcamguy cadcamguy is offline
external usenet poster
 
Posts: 11
Default looping thru the worksheet

I was using the ActiveCell.Offset(0, 1).Activate to loop thru my columns to
get the value of the cell

I understand that activating the cell is not needed and it slows thing down

I'm just kind of lost :-) on how I should do this without activating the
cell

What i am attemping to do is start at a certain row then read all the cols.
and then go to next row
comapare to see if they are the same or not... delete if they are and write
a little text file to list what got
blown out ...then go to the row below my first check and do it all over
again

I got my col count and can go across. then I offset back then down a row

this is a one shot that I have been using... should I just compare the whole
row and loop from there...thx

Open wrfile For Append As #1

For q = 1 To colct
ActiveCell.Offset(0, 1).Activate
tval(q) = ActiveCell.Value
If tval(q) = cval(q) Then ' see if values the same
ck(q) = 1 'same value
Else
ck(q) = 0 ' not the same
End If
Next q

ActiveCell.Offset(0, -(colct)).Activate 'return to start col

For q = 1 To colct ' add up check values
ckval = ckval + ck(q)
Next q

If ckval = colct Then ' delete if all ones pass if not

Print #1, ck_name & " replaced " & ActiveCell.Value

Worksheets("Sheet1").Rows(ActiveCell.Row).Delete
Else
ActiveCell.Offset(1, 0).Activate ' move down a row
End If
ckval = 0
TextBox1.Text = ActiveCell.Value
Close