+ Reply to Thread
Results 1 to 8 of 8

Formatting variances using .jpeg

Hybrid View

gagolmo Formatting variances using... 09-09-2014, 11:07 AM
Bernie Deitrick Re: Formatting variances... 09-09-2014, 01:32 PM
gagolmo Re: Formatting variances... 09-09-2014, 01:39 PM
Bernie Deitrick Re: Formatting variances... 09-09-2014, 02:11 PM
gagolmo Re: Formatting variances... 09-09-2014, 02:34 PM
Bernie Deitrick Re: Formatting variances... 09-09-2014, 03:22 PM
FDibbins Re: Formatting variances... 09-09-2014, 01:41 PM
gagolmo Re: Formatting variances... 09-09-2014, 01:46 PM
  1. #1
    Registered User
    Join Date
    06-20-2012
    Location
    dublin
    MS-Off Ver
    Excel 2010
    Posts
    4

    Formatting variances using .jpeg

    Hi There, could someone help me writing the IF statement that will apply green arrow up image when variance is greater than 0 and red arrow down image to negative variance?
    Thanks!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,273

    Re: Formatting variances using .jpeg

    You could use CF. For example, select the cells, choose CF / Icon Sets / More Rules... and then set the icon for > 0 to green arrow, and <0 to a red arrow.
    Last edited by Bernie Deitrick; 09-09-2014 at 01:36 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    06-20-2012
    Location
    dublin
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formatting variances using .jpeg

    Hi Bernie,
    The problem is that I want to use the images cause they are much sleeker. Do you know how to do that?
    Thank you for the replay!

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,273

    Re: Formatting variances using .jpeg

    Insert your two pictures onto the worksheet, and name them UpArrow and DownArrow

    Then copy this code, right-click the sheet tab, select "View Code" and paste the code into the window that appears. Then save the workbook as a macro-enabled .xlsm file. Change the "B:B" to the range of cells with the variance formulas.


    Private Sub Worksheet_Calculate()
    
    Dim myShape As Shape
    Dim r As Range
    Dim mySh As Worksheet
    
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Set mysht = ActiveSheet
    
    On Error Resume Next
    For Each myShape In mysht.Shapes
       If myShape.Name Like "*Final" Then myShape.Delete
    Next myShape
    
    For Each r In Range("B:B").SpecialCells(xlCellTypeFormulas)
    If r.Value > 0 Then
        ActiveSheet.Shapes("UpArrow").Select
        Selection.Copy
        r.Select
        ActiveSheet.Paste
    Else
        ActiveSheet.Shapes("DownArrow").Select
        Selection.Copy
        r.Select
        ActiveSheet.Paste
    End If
    
    Selection.Name = r.Address & "Final"
    Selection.Top = r.Top
    Selection.Left = r.Left
    Next r
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
    
    End Sub

  5. #5
    Registered User
    Join Date
    06-20-2012
    Location
    dublin
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formatting variances using .jpeg

    Bernie, it works for UpArrow but not for DownArrow, but probably I am not running this code correctly. And just one more question, how to place the arrows in C column next to variances in B? thanks

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,273

    Re: Formatting variances using .jpeg

    It should work for both - can you post your file?

    To place the pictures in the next column, use r(1,2) instead of r, like

    Private Sub Worksheet_Calculate()
    
    Dim myShape As Shape
    Dim r As Range
    Dim mySh As Worksheet
    
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Set mysht = ActiveSheet
    
    On Error Resume Next
    For Each myShape In mysht.Shapes
       If myShape.Name Like "*Final" Then myShape.Delete
    Next myShape
    
    For Each r In Range("B:B").SpecialCells(xlCellTypeFormulas)
    If r.Value > 0 Then
        ActiveSheet.Shapes("UpArrow").Select
        Selection.Copy
        r(1, 2).Select
        ActiveSheet.Paste
    Else
        ActiveSheet.Shapes("DownArrow").Select
        Selection.Copy
        r(1, 2).Select
        ActiveSheet.Paste
    End If
    
    Selection.Name = r(1, 2).Address & "Final"
    Selection.Top = r(1, 2).Top
    Selection.Left = r(1, 2).Left
    Next r
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    
    
    End Sub

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Formatting variances using .jpeg

    Conditional Formatting is designed for this, and will be much simpler
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Registered User
    Join Date
    06-20-2012
    Location
    dublin
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Formatting variances using .jpeg

    ok, thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Comparison of Variances
    By kwilkie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-30-2013, 11:43 AM
  2. [SOLVED] Monthly Variances shown by Conditional Formatting
    By rz6657 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-15-2013, 02:41 PM
  3. Excel 2007 : Largest Variances
    By MJDown in forum Excel General
    Replies: 10
    Last Post: 11-30-2011, 04:25 AM
  4. variances in two worksheets with ado and vba
    By pike in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-09-2011, 07:44 AM
  5. Calculate variances
    By Climaxgp in forum Excel General
    Replies: 11
    Last Post: 05-19-2009, 02:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1