Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you determine if it's the 1st row/col of a specified range?
Hi
Is there a piece of code that will allow me to decide whether a DummyCell is in the 1st row (or column) of a specified Range? I am interested in this as I wish to perform a special operation if it's the 1st row (or 1st column) Thanks very much for your help! SuperJas ------------------------- Sub Test( Dim DummyCell as Range, MyArea as Rang For Each DummyCell in MyArea.Cell <if it's the 1st row The ............ <If it's the 1st col The .......... Next DummyCel ----------------------------------------- |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you determine if it's the 1st row/col of a specified range?
Sub test()
Dim rngDummy As Range, rngMyRange As Range Set rngDummy = Range("B5") Set rngMyRange = Range("B2:F100") If rngDummy.Row = rngMyRange(1).Row Then Debug.Print "Same Row" End If If rngDummy.Column = rngMyRange(1).Column Then Debug.Print "Same Column" End If End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "SuperJas" wrote in message ... Hi, Is there a piece of code that will allow me to decide whether a DummyCell is in the 1st row (or column) of a specified Range? I am interested in this as I wish to perform a special operation if it's the 1st row (or 1st column). Thanks very much for your help! SuperJas. -------------------------- Sub Test() Dim DummyCell as Range, MyArea as Range For Each DummyCell in MyArea.Cells <if it's the 1st row Then ............. <If it's the 1st col Then ........... Next DummyCell ----------------------------------------- |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you determine if it's the 1st row/col of a specified range?
Another way is to test for intersect
For Each DummyCell In MyArea.Cells If Not Intersect(DummyCell, MyArea.Columns(1)) Is Nothing Then MsgBox "Cell " & DummyCell.Address & " in 1st column" End If If Not Intersect(DummyCell, MyArea.Rows(1)) Is Nothing Then MsgBox "Cell " & DummyCell.Address & " in 1st row" End If Next DummyCell -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Rob van Gelder" wrote in message ... Sub test() Dim rngDummy As Range, rngMyRange As Range Set rngDummy = Range("B5") Set rngMyRange = Range("B2:F100") If rngDummy.Row = rngMyRange(1).Row Then Debug.Print "Same Row" End If If rngDummy.Column = rngMyRange(1).Column Then Debug.Print "Same Column" End If End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "SuperJas" wrote in message ... Hi, Is there a piece of code that will allow me to decide whether a DummyCell is in the 1st row (or column) of a specified Range? I am interested in this as I wish to perform a special operation if it's the 1st row (or 1st column). Thanks very much for your help! SuperJas. -------------------------- Sub Test() Dim DummyCell as Range, MyArea as Range For Each DummyCell in MyArea.Cells <if it's the 1st row Then ............. <If it's the 1st col Then ........... Next DummyCell ----------------------------------------- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Determine if a value in a range is close to the value of another c | Excel Worksheet Functions | |||
Determine if a value in a range is close to the value of another c | Excel Worksheet Functions | |||
Determine whether a value is in a range of cells | Excel Discussion (Misc queries) | |||
Determine used range of worksheet | Excel Programming | |||
Determine range with VBA | Excel Programming |