A personal repository of technical notes. - CSC

Showing posts with label Excel. Show all posts
Showing posts with label Excel. Show all posts

Excel Alternating Rows Conditional Formatting Example

Problem
Need to format groups of matching rows with alternating colors.

Solution
Use a formula with conditional formatting.

1) Decide which column will be the "key column".
2) Sort sheet by key column.
3) Define a new Conditional Formatting column
  • Put "1" in column header row
  • Put formula in second row. Example: "=IF(A2=A1,D1,D1*-1)" where "A" is key column and "D" is Conditional Formatting column.
  • Copy formula into each row of column.

4) Define Conditional Formatting for alternating rows
  • Select all active cells in sheet
  • Click Conditional Formatting/New Rule...
  • Select Rule Type "Use a formula to determine which cells to format".
  • In "Format values where this formula is true:", define the Conditional Formatting column where = 1: Example: "=$D1=1" where "D" is Conditional Formatting column.



  • Click Format...
  • Select Fill tab, pick color, click OK, click OK.


Excel Tips

Create Custom Macro Workbook
  1. Create new workbook for custom macros.
  2. Save workbook in a folder with no other items.
  3. Hide workbook:
    Window/Hide
  4. Configure Custom Macro Workbook to automatically open by placing folder name in:
    Excel/Tools/Options/General/At startup, open all files in:
Dynamic Hyperlink Formula
View Web PageQuery String Value
=HYPERLINK("http://www.mydomain.com/mypage.htm?name="&B2, "View Web Page")MyValue1
=HYPERLINK("http://www.mydomain.com/mypage.htm?name="&B3, "View Web Page")MyValue2
=HYPERLINK("http://www.mydomain.com/mypage.htm?name="&B4, "View Web Page")MyValue3

Macro to Convert Text Hyperlink to Working Hyperlink

Sub HyperLinkConvert()
       ' From Microsoft: http://support.microsoft.com/kb/271856
       ' Converts each text hyperlink selected into a working hyperlink
       For Each xCell In Selection
              ActiveSheet.Hyperlinks.Add(Anchor:=xCell, Address:=xCell.Formula)
       Next xCell
End Sub

Updates
2012-10-30 Added "Macro to Convert Text Hyperlink"
2012-08-30 Added "Dynamic Hyperlink Formula"