Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default almost there ... code modify help

Hello -

I'm trying to modify some code I got from this Group and can't quite
seem to make it work ... hopefully, someone can help me out....

The code is supposed to -- go to each specified sheet, and value-out
links in light yellow cells, replacing #N/A with "". The code worked
fine before I tried to make it unprotect each sheet and replace the #N/
A's. I'd also like the code to ONLY re-protect sheets that were
originally protected -- the code currently doesn't address this need
at all.

Sub AABB()
Dim i As Long
Dim sh As Worksheet
Dim rng As Range
vArr = Array("P&L Summary", "P&L Acct Detail", "SALES", "FC
Scenarios", "CALCRENTALEQUP", "Capital Request 07", "Capital Request
08", "CALCINV", "GPR")
For i = LBound(vArr) To UBound(vArr)
Set sh = Worksheets(vArr(i))
sh.Unprotect Password:="busnav"
Set rng = sh.UsedRange
rng.Select
For Each Cell In Selection
Select Case Cell.Interior.ColorIndex
Case 36
Cell.Value = Cell.Value
End Select
Next Cell

sh.UsedRange.Replace What:="#N/A", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Range("A1").Select

sh.Protect Password:="busnav", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True
Next
End Sub


TIA for any help you can provide ....

Rgds, Ray

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default almost there ... code modify help

I added an activate statement to get it to run

Sub AABB()
Dim i As Long
Dim sh As Worksheet
Dim rng As Range
vArr = Array("P&L Summary", "P&L Acct Detail", "SALES", "FC Scenarios", _
"CALCRENTALEQUP", "Capital Request 07", "Capital Request 08", "CALCINV",
"GPR")
For i = LBound(vArr) To UBound(vArr)
Set sh = Worksheets(vArr(i))
sh.Unprotect Password:="busnav"
Worksheets(vArr(i)).Activate
Set rng = sh.UsedRange
rng.Select
For Each Cell In Selection
Select Case Cell.Interior.ColorIndex
Case 36
Cell.Value = Cell.Value
End Select
Next Cell

sh.UsedRange.Replace What:="#N/A", Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Range("A1").Select

sh.Protect Password:="busnav", DrawingObjects:=True, _
Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True
Next
End Sub


"Ray" wrote:

Hello -

I'm trying to modify some code I got from this Group and can't quite
seem to make it work ... hopefully, someone can help me out....

The code is supposed to -- go to each specified sheet, and value-out
links in light yellow cells, replacing #N/A with "". The code worked
fine before I tried to make it unprotect each sheet and replace the #N/
A's. I'd also like the code to ONLY re-protect sheets that were
originally protected -- the code currently doesn't address this need
at all.

Sub AABB()
Dim i As Long
Dim sh As Worksheet
Dim rng As Range
vArr = Array("P&L Summary", "P&L Acct Detail", "SALES", "FC
Scenarios", "CALCRENTALEQUP", "Capital Request 07", "Capital Request
08", "CALCINV", "GPR")
For i = LBound(vArr) To UBound(vArr)
Set sh = Worksheets(vArr(i))
sh.Unprotect Password:="busnav"
Set rng = sh.UsedRange
rng.Select
For Each Cell In Selection
Select Case Cell.Interior.ColorIndex
Case 36
Cell.Value = Cell.Value
End Select
Next Cell

sh.UsedRange.Replace What:="#N/A", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Range("A1").Select

sh.Protect Password:="busnav", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True
Next
End Sub


TIA for any help you can provide ....

Rgds, Ray


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
Modify code bigmaas Excel Discussion (Misc queries) 2 February 16th 10 10:51 AM
Modify Code Richard Excel Worksheet Functions 0 March 13th 08 08:19 PM
Modify code in UDF Biff Excel Programming 9 August 31st 05 04:41 AM
Help me modify this VBA code please: sanmisds1 Excel Programming 4 July 16th 05 04:48 AM
How to modify VBA code for Add-in? Shetty Excel Programming 1 March 3rd 04 04:04 PM


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