Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Highlight a Circular Ref

Very final post today-

I want to write a macro so that in column b of row 'x' of a spreadsheet
I will have a vlookup that will look at all the previous lines of the
spreadsheet.

I thought I could get around doing this by vlooking up all of the
column. However, this creates a circular reference that I cannot
find... so second question- is there any sort of 'if' statement that
would delete a circular reference and instead write text such as '#N/A'
or 'HERE'?

Many thanks.

Solomon

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Highlight a Circular Ref

Hi Soloman,

Chip Pearson suggested in this ng:
"
How about seeing if the Intersection of the cell and its precedents is
Nothing? If so, that cell does not have a circular reference. If not, it
does. E.g.,

If Not Application.Intersect(c, c.Precedents) Is Nothing Then
Msgbox "Has Circular Referece"
End If
"

which I've adapted

Sub test()
Dim rng As Range, cell As Range
On Error GoTo noFormulas
Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, 23)
On Error GoTo noPrecedent
For Each cell In rng
If Not Application.Intersect(cell, cell.Precedents) Is Nothing Then
cell.Interior.ColorIndex = 3 'colour circ-ref red
'or delete & write some text
'cell = "HERE"
End If
he
Next
noFormulas:
Exit Sub
noPrecedent:
Resume here
End Sub

Regards,
Peter T

"solomon_monkey" wrote in message
oups.com...
Very final post today-

I want to write a macro so that in column b of row 'x' of a spreadsheet
I will have a vlookup that will look at all the previous lines of the
spreadsheet.

I thought I could get around doing this by vlooking up all of the
column. However, this creates a circular reference that I cannot
find... so second question- is there any sort of 'if' statement that
would delete a circular reference and instead write text such as '#N/A'
or 'HERE'?

Many thanks.

Solomon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Highlight a Circular Ref

Thanks Peter... however, being as the vlookup is in column B regarding
column A and looks in A & B every reference is a circular reference...
this is fine for what I want it to do to a point... but only matters
when a vlookup would otherwise return an #N/A... Sorry to be awkward...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Highlight a Circular Ref

Without recreating your scenario I'm not quite sure what you need. If you
want to refine the search range to cells with errors, change

..SpecialCells(xlCellTypeFormulas, 23) 'all formulas
to
..SpecialCells(xlCellTypeFormulas, 16) 'formula errors only

Or record a macro, press F5 Special cells and whatever is appropriate.

And/or also some a nested If's perhaps

If InStr(cell.Formula, "VLOOKUP") then
if IsError(cell) then
If ... then

Regards,
Peter

"solomon_monkey" wrote in message
oups.com...
Thanks Peter... however, being as the vlookup is in column B regarding
column A and looks in A & B every reference is a circular reference...
this is fine for what I want it to do to a point... but only matters
when a vlookup would otherwise return an #N/A... Sorry to be awkward...



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
Circular or semi-circular chart DKS Charts and Charting in Excel 3 November 3rd 09 01:50 PM
how to highlight more related cells if cell highlight Jon Excel Discussion (Misc queries) 5 December 21st 08 01:06 PM
Circular Christine[_3_] Excel Worksheet Functions 3 November 12th 08 03:04 PM
Circular Margo Excel Worksheet Functions 7 November 4th 07 12:15 AM
Highlight cells with ctrl-click but only un-highlight one cell hagan Excel Discussion (Misc queries) 5 May 27th 05 06:45 PM


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