How to move to column B1 from column Z1
Hi Kiwis,
'---------------
my current cell is at column z1, i check for a condition,
if true then i move to column b1 to get the data, if not true, i move
to
next row & then test again.
how do i move to column b1 from column z1?
Do i use the offset function ?
'---------------
It is usually neither necessary nor desirable to select cells,
An appropriate code might be like:
'============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim Rng2 As Range
Dim rCell As Range
Const vVal = 5
Set WB = Workbooks("MyBook.xls") '<<=== CHANGE
Set SH = WB.Sheets("Sheet1") '<<=== CHANGE
Set Rng = SH.Range("Z1:Z100") '<<=== CHANGE
For Each rCell In Rng.Cells
With rCell
If .Value vVal Then
Set Rng2 = rCell.EntireRow.Cells(2)
MsgBox Rng2.Value
End If
End With
Next rCell
End Sub
'<<============
---
Regards,
Norman
|