Step through a range?

  • Thread starter Thread starter Kent McPherson
  • Start date Start date
K

Kent McPherson

I have a named range defined in 1 worksheet of my workbook. I want to step
through this range (e.g. 10 rows by 8 columns = 80 cells) one cell at a time
and based on a select case apply formatting to the same cell in another
worksheet in the same workbook. Can someone show me the construct to do
this? I'm no VBA expert as you can tell. Thanks.
 
Dim cell As Range

For Each cell in Range("myRange")
Select Case cell.Value
Case 1: 'do something
'etc.
End Select
Next cell

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
dim currRow as long
dim currCol as integer

for currRow=myRange.Row to myRange.Row+myRange.Rows.Count
for currCol=myRange.Columnto myRange.Column+myRange.Columnes.Count
select case cells(currRow,currCol)
Case 1:

sheets("OtherSheetName").cells(currRow,currCol).numberformat="%0.00"
end select
next
next

Peter Richardson
 

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

Back
Top