+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42
  1. #16
    Forum Guru sweep's Avatar
    Join Date
    04-03-2007
    Location
    Location: Location:
    MS-Off Ver
    XL2003 / 2007
    Posts
    2,447

    Re: What's in Your Personal.xls?

    A couple of functions that I find useful:

    Range
    Code:
    Function range(a As range)
    mmax = Application.WorksheetFunction.Max(a)
    mmin = Application.WorksheetFunction.Min(a)
    spread = Abs(mmax - mmin)
    End Function
    Multi cell concatenate
    Code:
     
    Function conc(a As range)
    Dim rcell As range, tmp As String
    For Each rcell In a
    tmp = tmp & rcell.Value & " "
    Next
    conc = tmp
    End Function
    interrogate cell colour
    Code:
     
    Function fillcolour(a As range)
    b = a.Interior.ColorIndex
    fillcolour = b
    End Function
    interrogate cell formula
    Code:
    Function form(a As range)
    form = a.Formula
    End Function
    Upper and Lower control limits:
    Code:
     
    Function UCL(dat As range)
    avg = Application.WorksheetFunction.Average(dat)
    sd3 = Application.WorksheetFunction.StDev(dat) * 3
    UCL = avg + sd3
    End Function
     
    Function LCL(dat As range)
    avg = Application.WorksheetFunction.Average(dat)
    sd3 = Application.WorksheetFunction.StDev(dat) * 3
    LCL = avg - sd3
    End Function
    Note that these are just to "get by" and don't error trap (and probably aren't particularly well written)

    Dave

  2. #17
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    3,713

    Re: What's in Your Personal.xls?

    DonkeyOte: oh my God I can't believe it, you're ... well it is uncanny except that my friend would have had difficulty spelling Excel never mind penetrating the mysteries of VBA. So, Damon Albarn left Essex did he once he made some money...who'd have thought it.

    Apologies to shg for derailing his thread.

    Thanks sweep - what do you use UCL and LCL for?

  3. #18
    Forum Guru sweep's Avatar
    Join Date
    04-03-2007
    Location
    Location: Location:
    MS-Off Ver
    XL2003 / 2007
    Posts
    2,447

    Re: What's in Your Personal.xls?

    Thanks sweep - what do you use UCL and LCL for?
    I used to use it all the time for control limits on XBar & R charts. However, no I have Minitab, it's not used so often...

  4. #19
    Forum Contributor
    Join Date
    04-03-2007
    Location
    Auckland, New Zealand
    MS-Off Ver
    2007
    Posts
    137

    Re: What's in Your Personal.xls?

    As I regulary use workbooks with many sheets, and often hide a number of sheets from time to time I find the below useful.


    Code:
    Sub UnHideSheets()
    For Each Sheet In ActiveWorkbook.Sheets
        If Sheet.Visible = False Then Sheet.Visible = True
    Next
        
    End Sub

  5. #20
    Forum Guru
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2003
    Posts
    2,286

    Re: What's in Your Personal.xls?

    I store the macros I've pinned to keyboard shortcuts in one module. I start them all ok (OnKey) so they're easy to discern/ignore in larger lists:
    Assigning the macros to various application.onkey strings is done in my personal.xls workbook open event.

    Code:
    Sub okRefitColumns()
        Columns.AutoFit
    End Sub
    
    Sub okCAGeneral()
        If Selection.HorizontalAlignment = xlCenterAcrossSelection Then
            Selection.HorizontalAlignment = xlGeneral
        Else
            Selection.HorizontalAlignment = xlCenterAcrossSelection
        End If
    End Sub
    
    Sub okDuplicateRow()
        Application.ScreenUpdating = False
        With ActiveCell.EntireRow
            .Copy
            .Insert
        End With
        With Application
            .CutCopyMode = False
            .ScreenUpdating = True
        End With
    End Sub
    
    Sub okDuplicateRowRev()
        On Error Resume Next
            ActiveCell(2).EntireRow.Delete
        On Error GoTo 0
    End Sub
    
    Sub okColourCycle()
    With Selection.Interior
        Select Case .ColorIndex
            Case -4142: .ColorIndex = 35
            Case 35: .ColorIndex = 39
            Case 39: .ColorIndex = 36
            Case 36: .ColorIndex = 37
            Case 37: .ColorIndex = 40
            Case 40: .ColorIndex = 34
            Case 34: .ColorIndex = 38
            Case Else: .ColorIndex = Null
        End Select
    End With
    End Sub
    I find the last of these very useful. Whilst working on a sheet, I can quickly colour cells needing special attention for any reason (I have pinned it to ctrl+g as I use Go To very rarely). The cycle is very powerful, once for green, twice for purple, etc. is super quick. Any "mixed" group is blanked first, then coloured (which can be quite helpful depending on which colour-happy mentalist sent you the sheet you're working on).

    CC

  6. #21
    Forum Moderator pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,141

    Re: What's in Your Personal.xls?

    Always at hand for working with PowerPoint, Word and large Data
    Code:
    Set SelectR = ActiveWindow.RangeSelection
        For Each Area In SelectR.Areas
            With Area
                .Select
                .Copy
                t = .Top
                h = .Height
                l = .Left
                w = .Width
            End With
            With ActiveSheet.Pictures.Paste(Link:=True)
                .Name = "OnePic"
                .ShapeRange.Fill.Solid
                .Top = t + h + 1
                .Left = l + w + 1
                .Top = t
                .Left = l
                .ShapeRange.ScaleWidth 1, msoFalse, msoScaleFromMiddle
                .ShapeRange.ScaleHeight 1, msoFalse, msoScaleFromMiddle
                .ShapeRange.Line.Weight = 1
                .ShapeRange.Fill.ForeColor.SchemeColor = 1
            End With
        Next Area
        SelectR.Select
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    JBeaucaires Excel Files

    VBA for smarties - snb

  7. #22
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,605

    Re: List Cell Text in Binary

    I utilize Named Ranges in many of my Excel apps. Occasionally, some bozo..um...I mean: an esteemed colleague will completely destroy key named ranges by deleting critical cells.

    I've gotten into the habit of using Insert.Name.Paste...Paste List
    to archive the definitions.

    My PERSONAL.XLS has this macro to convert that listing back into Named Ranges:

    Code:
    Sub CreateRangesFromList()
    'This procedure creates new range names in the active workbook
    'using a 2-column range of cells that contains:
    'Col 1: the text of the range name to be created
    'Col 2: text of the RefersTo definition (in proper format: ="somesheet!someref")
       Dim intRCount As Integer
       Dim intRRef As Integer
       
       Dim strSelAddr As String
       Dim rngBase As Range
       
       On Error GoTo FailTrap
       With selection
          If .Columns.Count <> 2 Then
             MsgBox Title:="Invalid Base Range", _
                   Prompt:="Range does not contain exactly 2 columns", _
                   Buttons:=vbCritical + vbOKOnly
             Exit Sub
          End If
          intRCount = .Rows.Count
          Set rngBase = .Cells(1, 1)
       End With
       
       With rngBase
             
          For intRRef = 1 To intRCount
    
             On Error Resume Next
             ActiveWorkbook.Names.Add _
                Name:=.Cells(intRRef, 1).Formula, _
                RefersTo:=.Cells(intRRef, 2).Formula
             If Err.Number <> 0 Then
                MsgBox Title:="Problem with this item:", _
                      Prompt:=.Offset(RowOffset:=intRRef).Address
             End If
          Next intRRef
       End With
       Set rngBase = Nothing
    Exit Sub
    
    FailTrap:
       Set rngBase = Nothing
       MsgBox Title:="Problems Encountered", _
             Prompt:="Check list for invalid Range Name Text and/or Refers_To values.", _
             Buttons:=vbCritical + vbOKOnly
             
    End Sub
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  8. #23
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: What's in Your Personal.xls?

    ron i thought i could use that code to insert multiple tables but i keep getting error
    any ideas?
    Attached Files Attached Files
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #24
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,605

    Re: What's in Your Personal.xls?

    Quote Originally Posted by martindwilson View Post
    ron i thought i could use that code to insert multiple tables but i keep getting error
    any ideas?
    Using your posted workbook I didn't have any trouble.
    On Sheet2, where Col_A contains the "Names" and Col_B contains the "Refers To" expression.
    Here's what I did:

    1) Select A1:B101
    2) Tools.Macro.Macros....CreateRangesFromList....Click: Run

    All of the range names were created.

    Did you select the 2-col list before running the macro?
    Last edited by Ron Coderre; 07-18-2009 at 10:31 PM. Reason: Corrected mindless typos :\
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  10. #25
    Forum Guru
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2003
    Posts
    2,286

    Re: What's in Your Personal.xls?

    You should make the two column list a named range so you wouldn't need to bother with that first bit... oh wait...

  11. #26
    Forum Moderator pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,141

    Re: What's in Your Personal.xls?

    Thanks Ron
    another keeper
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    JBeaucaires Excel Files

    VBA for smarties - snb

  12. #27
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,477

    Re: What's in Your Personal.xls?

    cheers ron, guess who selected whole range a:b instead of a1:b101, oops
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  13. #28
    Forum Guru
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2003
    Posts
    2,286

    Re: What's in Your Personal.xls?

    I wrote this recently, trying to decipher a really mixed up worksheet, with multiple different formulae at different points in columns & rows.
    The comments show exactly how it works, but in summary, it returns true if the formulae of the two specified cells are equivalent (based on relative referencing, of course).

    Code:
    Function compare(Cell1 As range, cell2 As range)
        If Not Cell1.HasFormula And Not cell2.HasFormula Then
            'Neither have formulae, don't compare values, automatic pass
            compare = True
        ElseIf Cell1.HasFormula And cell2.HasFormula Then
            'Both have formulae, compare formulae
            compare = Cell1.FormulaR1C1 = cell2.FormulaR1C1
        Else
            'One has formula, one not, automatic fail
            compare = False
        End If
    End Function

  14. #29
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    Location
    Leeds, UK
    MS-Off Ver
    2003 (work), 2007 & 2010 (home)
    Posts
    3,504

    Re: What's in Your Personal.xls?

    I love my Personal.xls, have all sorts of useful stuff in it that helps me with my job.

    From the top...

    - a bunch of subs that summarise/format SAP reports in different ways depending on what I want to do with them
    - a batch pdf creator
    - functions for counting/summing by font and colour. These aren't really for me but many people I work with have a habit of colouring cells/text and then realise they can't add the colours up.
    - a toggle between manual and automatic calculation
    - one that summarises consecutively dated records that SAP throws out
    - one that compares worksheets and reports the differences
    - a password breaker (don't tell)
    - delete all named ranges
    - file lister
    - Chip Pearson's ImportBigTextFiles

    I never realised there was quite so much in here...loads of other little functions and things that I've written or stolen over time really.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    If you haven't already please take some time to read the Forum Rules.

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  15. #30
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,427

    Re: What's in Your Personal.xls?

    Just had time to read through this one. I don't have a Personal.xls, I prefer the mobility of an addin.

    I also keep a large database of code snippets.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

Thread Information

Users Browsing this Thread

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

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.2.0