LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determine the Row in a Range

Public Sub DateCopy()
Dim rngCell As Worksheet
Dim FndRng As Range
Dim x As String

For i = 2 To 5547
Set rngCell = Workbooks("test.xls").Sheets("testsheet")
Set FndRng =
Workbooks("test2.xls").Sheets("testsheet2").Range( "A:A").Find(rngCell.Rows(i
).Columns("A").Value)

If Not FndRng Is Nothing Then
Set Sh = FndRng.Parent
rw = FndRng.Row
If sh.Cells(rw,3).Value = "Yes" Then
MsgBox "This Cell's Value has already been pulled once!! (Possible
Duplicate)", vbExclamation
' sh.Cells(rw,4).Value = rngCell.Rows(i).Columns("A").Value
rngCell.Rows(i).Columns("D").Value = "Duplicate?"
Else
sh.Cells(rw, 3).Value = "Yes"
rngCell.Rows(i).Columns("D").Value = sh.Cells(rw, 2).Value
End If
End If
Next

End Sub

--
Regards,
Tom Ogilvy

"Dan" wrote in message
...
I have the code below, which works great. But rather than setting the

values in the second sheet's columns using the .Offset method, I would
rather be able to determine the FndRng's current row and use that along with
the column I want data to be entered into to set a value. Instead of
relying upon the offset method (FndRng.Offset(0, 3).Value = "Yes").
I guess I just need to know how to set the row of a range to a variable,

or a column for that matter. Thanks a lot!

Public Sub DateCopy()
Dim rngCell As Worksheet
Dim FndRng As Range
Dim x As String

For i = 2 To 5547
Set rngCell = Workbooks("test.xls").Sheets("testsheet")
Set FndRng =

Workbooks("test2.xls").Sheets("testsheet2").Range( "A:A").Find(rngCell.Rows(i
).Columns("A").Value)

If Not FndRng Is Nothing Then
If FndRng.Offset(0, 3).Value = "Yes" Then
MsgBox "This Cell's Value has already been pulled once!! (Possible

Duplicate)", vbExclamation
' FndRng.Offset(0, 4).Value = rngCell.Rows(i).Columns("A").Value
rngCell.Rows(i).Columns("D").Value = "Duplicate?"
Else
FndRng.Offset(0, 3).Value = "Yes"
rngCell.Rows(i).Columns("D").Value = FndRng.Offset(0, 2).Value
End If
End If
Next

End Sub



 
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 Marcelo Excel Worksheet Functions 0 June 7th 06 07:46 PM
How do you determine if it's the 1st row/col of a specified range? SuperJas Excel Programming 2 April 7th 04 09:46 AM
How to determine a range size cici Excel Programming 1 February 11th 04 10:16 PM
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 01:36 AM.

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

About Us

"It's about Microsoft Excel"