#1   Report Post  
Kevin
 
Posts: n/a
Default cell contents

Hi
the code below returns the address of a cell on a worksheet
what i want to do is return the cell address subtract 10 from address
and read the contents of the new cell address
ie cell address = F15
subtract 10 from this to give F5
F5 contains the value 6
i want to reurn 6 as the answer

Sub kevin()
Dim rng As Range
Dim cell As Range
Dim rngData As Range
Set rng = Range("D15:H15")
For Each cell In rng
If cell.Text < "#N/A" Then
MsgBox cell.Address
Exit For
End If
Next

thanks

kevin
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Sub kevin()
Dim rng As Range
Dim cell As Range
Dim rngData As Range
Set rng = Range("D15:H15")
For Each cell In rng
If cell.Offset(-10,0).Text < "#N/A" Then
MsgBox cell.Offset(-10,0).Value
Exit For
End If
Next

but why not just do

Sub kevin()
Dim rng As Range
Dim cell As Range
Dim rngData As Range
Set rng = Range("D5:H5")
For Each cell In rng
If cell.Text < "#N/A" Then
MsgBox cell.Value
Exit For
End If
Next

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Kevin" wrote in message
om...
Hi
the code below returns the address of a cell on a worksheet
what i want to do is return the cell address subtract 10 from address
and read the contents of the new cell address
ie cell address = F15
subtract 10 from this to give F5
F5 contains the value 6
i want to reurn 6 as the answer

Sub kevin()
Dim rng As Range
Dim cell As Range
Dim rngData As Range
Set rng = Range("D15:H15")
For Each cell In rng
If cell.Text < "#N/A" Then
MsgBox cell.Address
Exit For
End If
Next

thanks

kevin



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
Can I use the contents of a cell to satisfy the result_vector arg. robh_2 Excel Worksheet Functions 3 February 24th 05 08:14 PM
Adding contents of one cell to a range of cells. CLJinVA Excel Worksheet Functions 1 February 10th 05 10:19 PM
Cell contents vs. Formula contents Sarah Excel Discussion (Misc queries) 3 December 15th 04 06:02 PM
Display actual contents of cell xmasbob Excel Discussion (Misc queries) 1 December 6th 04 05:09 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 12:46 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"