PDA

View Full Version : How do you read all cells in a row?



doctortt
11-20-2012, 07:43 AM
Hi guys,

I'm a newbie. I was reading this excel vba book, and I couldn't figure it out. I need to know how to read all cells in a specific row to see whether it matches a particular cell with a hard-coded value. Your help is greatly appreciated.

GarysStudent
11-20-2012, 09:07 AM
Give this a try:

Sub RowCheck()
Dim v As Variant
v = Range("A1").Value
For Each cel In Rows(11).Cells
If cel.Value = v Then
MsgBox "Value found in cell " & cel.Address
Exit Sub
End If
Next
MsgBox "Value not found"
End Sub