Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default select all cells in an active sheet containg links to other (external) workbooks.

How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??



Thxs

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default select all cells in an active sheet containg links to other (external) workbooks.

The question back is why do you need to select? You can do almost anything
desired without ever making selections.

--
Don Guillett
SalesAid Software

"al007" wrote in message
oups.com...
How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??



Thxs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default select all cells in an active sheet containg links to other (exter

To select a set of cells that meet a criteria, let's build the range with
unions and then select the built range:


Sub selector()
Dim r As Range
Dim rr As Range
For Each r In ActiveSheet.UsedRange
If Left(r.Formula, 2) = "=[" Then
If rr Is Nothing Then
Set rr = r
Else
Set rr = Union(rr, r)
End If
End If
Next
rr.Select
End Sub


Here we build rr one cell at a time and then do a single selection of all
the celss in it.
--
Gary''s Student


"al007" wrote:

How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??



Thxs


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default select all cells in an active sheet containg links to other(external) workbooks.

And remember that not all formulas that link back to other workbooks start with
=[.



al007 wrote:

How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??

Thxs


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default select all cells in an active sheet containg links to other (external) workbooks.

you are perfectly right - how can what code would identify links to
workbooks which are closed?


i.e If Left(cell.Formula, 2) contains ":\" Then 'then select

thxs



Dave Peterson wrote:
And remember that not all formulas that link back to other workbooks start with
=[.



al007 wrote:

How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??

Thxs


--

Dave Peterson




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default select all cells in an active sheet containg links to other (exter

does not seem to work - can u help
Gary''s Student wrote:
To select a set of cells that meet a criteria, let's build the range with
unions and then select the built range:


Sub selector()
Dim r As Range
Dim rr As Range
For Each r In ActiveSheet.UsedRange
If Left(r.Formula, 2) = "=[" Then
If rr Is Nothing Then
Set rr = r
Else
Set rr = Union(rr, r)
End If
End If
Next
rr.Select
End Sub


Here we build rr one cell at a time and then do a single selection of all
the celss in it.
--
Gary''s Student


"al007" wrote:

How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??



Thxs



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default select all cells in an active sheet containg links to other(external) workbooks.

looking for :\ is a problem on links to files that are on network shares:

\\server\share\folder\myfile.xls

You could look for [ or ] or .xls a combination of these.

But they could be embedded into strings, too. So it's not foolproof.

But you will want to limit yourself to just the formulas.

This may yield some "false positives" if you have formulas that contain .xls or
[ or ].

Option Explicit
Sub testme()

Dim myRng As Range
Dim myExtLinkRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myList As Variant
Dim iCtr As Long
Dim FirstAddress As String
Dim FoundCell As Range

Set wks = Worksheets("sheet1")

myList = Array(".xls", "[", "]")

Set myRng = Nothing
On Error Resume Next
Set myRng = wks.UsedRange.Cells.SpecialCells(xlCellTypeFormula s)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No formulas!"
Exit Sub
End If

With myRng
For iCtr = LBound(myList) To UBound(myList)
Set FoundCell = .Cells.Find(what:=myList(iCtr), _
LookIn:=xlFormulas, _
lookat:=xlPart, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'do nothing, not found
Else
FirstAddress = FoundCell.Address
Do
If myExtLinkRng Is Nothing Then
Set myExtLinkRng = FoundCell
Else
If Intersect(myExtLinkRng, FoundCell) Is Nothing Then
Set myExtLinkRng = Union(myExtLinkRng, FoundCell)
Else
'already part of the range
End If
End If
Set FoundCell = .FindNext(FoundCell)
If FoundCell.Address = FirstAddress Then
Exit Do
End If
Loop
End If
Next iCtr
End With

If myExtLinkRng Is Nothing Then
MsgBox "I didn't find it"
Else
MsgBox "maybe it's part of the selected range"
Application.Goto myExtLinkRng
End If

End Sub


======
If I were really looking for links to other workbooks, I'd use Bill Manville's
FindLink program:
http://www.oaltd.co.uk/MVP/Default.htm

al007 wrote:

you are perfectly right - how can what code would identify links to
workbooks which are closed?

i.e If Left(cell.Formula, 2) contains ":\" Then 'then select

thxs

Dave Peterson wrote:
And remember that not all formulas that link back to other workbooks start with
=[.



al007 wrote:

How can i make the code below select all cells in an active sheet
containg links to other (external) workbooks.

For Each cell In ActiveSheet.UsedRange
If Left(cell.Formula, 2) = "=[" Then 'then select
cells how to put selection code??

Thxs


--

Dave Peterson


--

Dave Peterson
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
How to set printer default to select active sheet not whole book Vic Storey Excel Discussion (Misc queries) 0 May 16th 08 06:11 PM
how do I break links to external workbooks en masse? Dave F Excel Discussion (Misc queries) 7 November 9th 07 09:52 PM
How to select the active sheet? Eric Excel Worksheet Functions 1 August 7th 07 03:40 PM
Shade cells with links to external workbooks Steph[_6_] Excel Programming 2 September 6th 05 08:45 PM
how do I activate links without opening external workbooks? teh_chucksta Excel Discussion (Misc queries) 0 August 29th 05 11:22 PM


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