Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine if a value in a range is close to the value of another c Raven Excel Worksheet Functions 0 June 7th 06 07:47 PM
Determine if a value in a range is close to the value of another c Marcelo Excel Worksheet Functions 0 June 7th 06 07:46 PM
Determine whether a value is in a range of cells Carl Excel Discussion (Misc queries) 2 December 12th 05 12:23 AM
Determine used range of worksheet Ian Smith[_3_] Excel Programming 4 February 11th 04 03:19 PM
Determine range with VBA Bryon[_2_] Excel Programming 1 October 25th 03 06:52 PM


All times are GMT +1. The time now is 03:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"