Executing two statements in a for loop

M

mail693174

Hey guys I am new at macos

I basically have a column with both numbers and blank cells (column H).
I am trying to recognize only the numbers and copy them in the adjacent
column one after another.
When the cell is actually a number, I would like to increment a counter
starting from cell i11.
If I try to add a second If statement in the for loop for the sole
purpose of incrementing the counter I get an error

here is the code:

Sub rechercheFinale2()
Dim cell As Range
Dim index As Integer
index = 11
For Each cell In Range("H11:H402")
If IsNumeric(cell.Value) = True Then
Worksheets("Sheet1").Rows(index).Columns(9).Value = cell.Value
index = index + 1
Next cell
End Sub



thank you guys
 
B

Bob Phillips

Sub rechercheFinale2()
Dim cell As Range
Dim index As Integer
index = 11
For Each cell In Range("H11:H402")
If IsNumeric(cell.Value) Then
cell.Value.Copy Worksheets("Sheet1").Cells(index, "I").Value
index = index + 1
End If
Next cell
End Sub



--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
M

mail693174

Its funny, I noticed the code I was working with actually had two index

Sub rechercheFinale2()
Dim cell As Range
Dim index As Integer
index = 11
For Each cell In Range("H11:H402")
index = index + 1
If IsNumeric(cell.Value) = True Then
Worksheets("Sheet1").Rows(index).Columns(9).Value = cell.Value
index = index + 1
End If
Next cell
End Sub

the version I posted actually works, but yours is cleaner

Thank you for your help


Bob Phillips a écrit :
 

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

Top