Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default Macro

Need help with this macro. Allows my scorecard to update indicator lights
depending on performance. However, I can't get the lights to center in the
cell. This same macro would center the indicator image in Excel 2002 but
does not work in 2007. Any ideas?


Public Sub Update_Light_Images()
On Error GoTo HandleError:

Dim myCell As Range
Dim OrigCell As Range
Dim ScorecardSheet As Worksheet
Dim ImageName As String
Dim sh As Shape

Set OrigCell = Selection
Set ScorecardSheet = Range("KeyCells").Worksheet

With Application
.EnableEvents = False
.DisplayAlerts = False
.ScreenUpdating = False
End With

'delete all of the Stoplight images but leave the other pictures
'The name of the other pictures on the page must not end with "Image"
For Each sh In ScorecardSheet.Shapes
Select Case Right(sh.Name, 5)
Case "Image"
sh.Delete
Case Else
'don't delete the object
End Select
Next

'For the KeyCell named range cells, paste in an image ball
'from the worksheet 'Images' that corresponds to the value
'text from the KeyCell -- Red, Green, Yellow.
For Each myCell In Range("KeyCells")
Select Case myCell.Value
Case "Red", "Yellow", "Green"
ScorecardSheet.Activate
ImageName = myCell.Address & "Image"
Sheets("Images").Shapes(myCell.Value & "Ball").Copy
ScorecardSheet.Activate
myCell.Select
ActiveSheet.Paste
Selection.Name = ImageName
Selection.ShapeRange.ZOrder msoBringToFront
End Select
Next myCell

Range("a1").Select

OrigCell.Worksheet.Activate
OrigCell.Select

SubFinish:
With Application
.EnableEvents = True
.DisplayAlerts = True
.ScreenUpdating = True
End With

Exit Sub
HandleError:
Select Case Err.Number
Case -2147024809 'if the image name doesn't exist
Resume Next
Case Else
Resume Next
' MsgBox Err.Number & ": " & Err.Description
' GoTo SubFinish
End Select
End Sub


 
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM


All times are GMT +1. The time now is 08:47 PM.

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"