Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Hardcode links - loop through sheets

Hello. Below I have a bit of code that hardcodes links to external
workbooks within the ActiveSheet. Can someone please modify this to loop
through all sheets in ThisWorkbook? Thank you!

Sub Hardcode()


Dim ws As Worksheet
On Error Resume Next
Set rng = ActiveSheet.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If rng = Empty Then
MsgBox ("No Links in Sheets")
Else
For Each cell In rng
sform = cell.Formula
If InStr(sform, "[") Then
cell.Formula = cell.Value
End If
Next
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hardcode links - loop through sheets

Sub Hardcode2()

Dim ws As Worksheet
Dim cell as range
dim rng as range
dim sForm as string

For each ws in activeworkbook.worksheets
set rng = nothing
On Error Resume Next
Set rng = ws.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If rng is nothing Then
MsgBox "No Links in: " & ws.name
Else
For Each cell In rng
sform = cell.Formula
If InStr(sform, "[") Then
cell.Formula = cell.Value
End If
Next cell
End If
next ws
End Sub

(Watch out for typos)

Steph wrote:

Hello. Below I have a bit of code that hardcodes links to external
workbooks within the ActiveSheet. Can someone please modify this to loop
through all sheets in ThisWorkbook? Thank you!

Sub Hardcode()

Dim ws As Worksheet
On Error Resume Next
Set rng = ActiveSheet.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If rng = Empty Then
MsgBox ("No Links in Sheets")
Else
For Each cell In rng
sform = cell.Formula
If InStr(sform, "[") Then
cell.Formula = cell.Value
End If
Next
End If
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Hardcode links - loop through sheets

Thanks Dave!!

"Dave Peterson" wrote in message
...
Sub Hardcode2()

Dim ws As Worksheet
Dim cell as range
dim rng as range
dim sForm as string

For each ws in activeworkbook.worksheets
set rng = nothing
On Error Resume Next
Set rng = ws.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If rng is nothing Then
MsgBox "No Links in: " & ws.name
Else
For Each cell In rng
sform = cell.Formula
If InStr(sform, "[") Then
cell.Formula = cell.Value
End If
Next cell
End If
next ws
End Sub

(Watch out for typos)

Steph wrote:

Hello. Below I have a bit of code that hardcodes links to external
workbooks within the ActiveSheet. Can someone please modify this to loop
through all sheets in ThisWorkbook? Thank you!

Sub Hardcode()

Dim ws As Worksheet
On Error Resume Next
Set rng = ActiveSheet.Cells.SpecialCells(xlFormulas)
On Error GoTo 0
If rng = Empty Then
MsgBox ("No Links in Sheets")
Else
For Each cell In rng
sform = cell.Formula
If InStr(sform, "[") Then
cell.Formula = cell.Value
End If
Next
End If
End Sub


--

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
Y Axis : Dynamically Hardcode Min/Max Values? RayportingMonkey Charts and Charting in Excel 1 February 21st 08 06:06 PM
hardcode a column in a formula AHizon via OfficeKB.com Excel Worksheet Functions 2 October 16th 07 01:33 AM
Hardcode Links - edit my code please? Steph[_6_] Excel Programming 1 October 26th 05 04:14 PM
Change hardcode to ....? Stuart[_21_] Excel Programming 3 April 30th 05 05:53 PM
Loop across Sheets and number of sheets Raj[_8_] Excel Programming 2 December 18th 03 09:18 AM


All times are GMT +1. The time now is 09:07 PM.

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"