Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #16  
Old 06-19-2009, 08:32 AM
sweep's Avatar
sweep sweep is offline
Forum Guru
 
Join Date: 03 Apr 2007
Location: Skelmersdale UK, probably.
MS Office Version:XL2003 / 2007
Posts: 1,721
sweep is very confident of their ability sweep is very confident of their ability sweep is very confident of their ability sweep is very confident of their ability
Re: What's in Your Personal.xls?

Please Register to Remove these Ads

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
Reply With Quote
  #17  
Old 06-19-2009, 09:27 AM
StephenR StephenR is offline
Forum Guru
 
Join Date: 26 Aug 2007
Location: London
Posts: 2,210
StephenR is very confident of their ability StephenR is very confident of their ability StephenR is very confident of their ability StephenR is very confident of their ability StephenR is very confident of their ability
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?
Reply With Quote
  #18  
Old 06-19-2009, 09:46 AM
sweep's Avatar
sweep sweep is offline
Forum Guru
 
Join Date: 03 Apr 2007
Location: Skelmersdale UK, probably.
MS Office Version:XL2003 / 2007
Posts: 1,721
sweep is very confident of their ability sweep is very confident of their ability sweep is very confident of their ability sweep is very confident of their ability
Re: What's in Your Personal.xls?

Quote:
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...
Reply With Quote
  #19  
Old 07-12-2009, 05:39 AM
Jbentley Jbentley is offline
Forum Contributor
 
Join Date: 03 Apr 2007
Location: Auckland, New Zealand
MS Office Version:2007
Posts: 121
Jbentley has been very helpful
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
Reply With Quote
  #20  
Old 07-17-2009, 09:26 AM
Cheeky Charlie Cheeky Charlie is offline
Valued Forum Contributor
 
Join Date: 27 Aug 2008
Location: England
MS Office Version:2003
Posts: 1,547
Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability
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
Reply With Quote
  #21  
Old 07-17-2009, 11:30 PM
pike's Avatar
pike pike is offline
Forum Guru
 
Join Date: 11 Dec 2005
Location: Moruya, Australia
MS Office Version:2007
Posts: 1,549
pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World
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

Always add code tags to your VBA script [code] .Range("A1:A10").RemoveDuplicates [/code]
Code:
 .Range("A1:A10").RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
Remember to change the prefix to [SOLVED]
If the solution helped and you wish to add to the contributors reputation, click the.... .... icon in top right hand corner of the thread ......... ã
Spreadsheet Toolbox
Reply With Quote
  #22  
Old 07-17-2009, 11:43 PM
Ron Coderre's Avatar
Ron Coderre Ron Coderre is offline
Cheeky Forum Moderator
 
Join Date: 22 Mar 2005
Location: Boston, Massachusetts
MS Office Version:Versions 2003 and 2007
Posts: 2,799
Ron Coderre is very confident of their ability Ron Coderre is very confident of their ability Ron Coderre is very confident of their ability Ron Coderre is very confident of their ability
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)

Click here to see the Forum Rules
Reply With Quote
  #23  
Old 07-18-2009, 03:55 AM
martindwilson's Avatar
martindwilson martindwilson is online now
Forum Guru
 
Join Date: 23 Jun 2007
Location: London,England
MS Office Version:office 97 ,2003 ,2007
Posts: 6,073
martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding
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
File Type: xls INSERT TABLES.xls (43.5 KB, 6 views)
__________________
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code

how to enter array formula


recommended reading
wiki Mojito

how to say no convincingly

most important think you need
Reply With Quote
  #24  
Old 07-18-2009, 08:38 AM
Ron Coderre's Avatar
Ron Coderre Ron Coderre is offline
Cheeky Forum Moderator
 
Join Date: 22 Mar 2005
Location: Boston, Massachusetts
MS Office Version:Versions 2003 and 2007
Posts: 2,799
Ron Coderre is very confident of their ability Ron Coderre is very confident of their ability Ron Coderre is very confident of their ability Ron Coderre is very confident of their ability
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?
__________________
Regards,

Ron
Microsoft MVP (Excel)

Click here to see the Forum Rules

Last edited by Ron Coderre; 07-18-2009 at 09:31 PM. Reason: Corrected mindless typos :\
Reply With Quote
  #25  
Old 07-18-2009, 05:08 PM
Cheeky Charlie Cheeky Charlie is offline
Valued Forum Contributor
 
Join Date: 27 Aug 2008
Location: England
MS Office Version:2003
Posts: 1,547
Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability
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...
Reply With Quote
  #26  
Old 07-19-2009, 12:45 AM
pike's Avatar
pike pike is offline
Forum Guru
 
Join Date: 11 Dec 2005
Location: Moruya, Australia
MS Office Version:2007
Posts: 1,549
pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World pike is a becoming a god in the Excel Forum World
Re: What's in Your Personal.xls?

Thanks Ron
another keeper
__________________
.

regards pike

Always add code tags to your VBA script [code] .Range("A1:A10").RemoveDuplicates [/code]
Code:
 .Range("A1:A10").RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
Remember to change the prefix to [SOLVED]
If the solution helped and you wish to add to the contributors reputation, click the.... .... icon in top right hand corner of the thread ......... ã
Spreadsheet Toolbox
Reply With Quote
  #27  
Old 07-19-2009, 11:00 AM
martindwilson's Avatar
martindwilson martindwilson is online now
Forum Guru
 
Join Date: 23 Jun 2007
Location: London,England
MS Office Version:office 97 ,2003 ,2007
Posts: 6,073
martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding martindwilson Has a higher level of understanding
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


recommended reading
wiki Mojito

how to say no convincingly

most important think you need
Reply With Quote
  #28  
Old 07-31-2009, 03:54 PM
wanrom wanrom is offline
Registered User
 
Join Date: 31 Jul 2009
Location: USA
MS Office Version:Excel 2003
Posts: 2
wanrom is becoming part of the community
Re: What's in Your Personal.xls?

Excel 2002, part of Office XP.

Is there somewhere other than in PERSONAL.XLS to store a macro for general use by any spreadsheet?

I’d like the macro to be available to any spreadsheet, but I don’t want to have EXCEL open PERSONAL.XLS every time I start the program, which is what happens if I put the macro in PERSONAL.XLS.

Thanks.
__________________
Roxy Stickers
Reply With Quote
  #29  
Old 07-31-2009, 08:52 PM
shg's Avatar
shg shg is offline
Forum Guru
 
Join Date: 20 Jun 2007
Location: The Great State of Texas
MS Office Version:2003, 2007
Posts: 18,493
shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay
Re: What's in Your Personal.xls?

Welcome to the forum.

This formum (Tips and Tutorials) is not for questions. Please take a few minutes to read the forum rules, and then post in one of the question forums.
__________________
Entia non sunt multiplicanda sine necessitate.
Reply With Quote
  #30  
Old 12-02-2009, 05:31 AM
Cheeky Charlie Cheeky Charlie is offline
Valued Forum Contributor
 
Join Date: 27 Aug 2008
Location: England
MS Office Version:2003
Posts: 1,547
Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability Cheeky Charlie is very confident of their ability
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
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump