m2oTech.com

  • Increase font size
  • Default font size
  • Decrease font size
What I Learned Today

A macro to un-mess Excel comments

Print PDF

Ever experienced having tens of comments in Excel and finding they are all over the place (e.g. because you resized/added/removed cells)? I was quite sure there must be a better way and someone already did a macro to "fix" this... so here it is, I found this originally posted at this blog and allowed myself to copy and paste it (if you are the author and you want credits please let me know!).

All you need to do is:

  1. Add a macro to your spreadsheet (not "record a macro")
  2. In the VBA editor that opens paste the following code
  3. Optionally create a shortcut to the macro so that you can invoke it easily (else can run it from menu when needed)

This macro will place all of your comments back to where they belong (next to the cell they refer to).

Note: If you are trying to find a way to move comments on the sheet where you would like them to be... that's a different story. It does not seem to be possible!

Sub CommentFix()

' This macro modifies all comments in all open workbooks to:
' (1) move and size with cells
' (2) be physically positioned near the cell to which they correspond
' (3) be optimally sized appropriate to the text within
' This macro was created by combining code posted on the following website:
' http://www.contextures.com/xlcomments03.html

Dim thisfile As Workbook
Set thisfile = ActiveWorkbook
Dim MyWorkbook As Workbook
Dim MySheet As Worksheet
Dim MyComment As Comment
Dim CommentCount As Long
Dim lArea As Long
Dim fixed As Boolean
fixed = False
On Error GoTo NeedToUnprotect
For Each MyWorkbook In Workbooks
MyWorkbook.Activate
For Each MySheet In MyWorkbook.Sheets
MySheet.Activate
CommentCount = 0
For Each MyComment In MySheet.Comments
With MyComment.Shape
.Placement = xlMoveAndSize
.Top = MyComment.Parent.Top + 5
.Left = MyComment.Parent.Offset(0, 1).Left + 5
.TextFrame.Characters.Font.Name = "Tahoma"
.TextFrame.Characters.Font.Size = 8
.TextFrame.AutoSize = True
CommentCount = CommentCount + 1
End With
If MyComment.Shape.Width > 300 Then
lArea = MyComment.Shape.Width * MyComment.Shape.Height
MyComment.Shape.Width = 200
MyComment.Shape.Height = (lArea / 200) * 1.1
End If
Next MyComment
If CommentCount > 0 Then
MsgBox ("A total of " & CommentCount & " comments in worksheet '" & MySheet.Name & "' of workbook '" & MyWorkbook.Name & "'" & Chr(13) & "were repositioned and resized.")
fixed = True
End If
Next MySheet
Next MyWorkbook
thisfile.Activate
If fixed = False Then
MsgBox ("No comments were detected.")
End If
On Error GoTo 0
Exit Sub

NeedToUnprotect:
MsgBox ("You must unprotect all worksheets before running the macro.")
thisfile.Activate
Exit Sub

End Sub

 

 

BCD - A different kind of binaries

Print PDF

Decimal "08" gets coded in binary as "0000 1000", that's because the hexadecimal representation of the number is also "08".

but

Decimal "39" does not get coded as "0011 1001", because its hexadecimal representation is "27" (thus binary "0010 0111").

There is however a coding system called BCD (Binary Coded Decimal) which would code "39" exactly as "0011 1001". In other words BCD does with decimals what you'd normally do with hexadecimals, i.e. take each digit and "translate" it to a half-a-byte (a nibble) binary number. As only values from 0 to 9 can be represented by a decimal digit, only binary values from 0000 to 1001 can be "translated" (1010 to 1111 remain unused).

While this is mostly a relict of "old times" there are still areas where BCD is used. A good example are digital clocks, since some chips translate directly binary digits into 0-9 digits, without having to worry about characters like A-F, which would be present if translating to hexadecimals. Or, and that is how I learned about the existence of BCD, in some digital controls for lighting devices (DALI standard).

This topic on Wikipedia.

 

How to Enter God Mode in Windows 7 or Vista

Print PDF

This is a really cool little trick. Want to have all admin controls available in one place (actually one "folder")? All you need to do is create a folder somewhere and rename it to

godmode.{ED7BA470-8E54-465E-825C-99712043E01C}

Inside this folder a lot of items will appear, everything from Device Manager to Firewall, Printer, Sharing settings and many more will be just a click away.


 

Proxing a cybercrime? Not too remote a possibility

Print PDF

I've often wandered who would be willing to "donate" his or her own computer to work as a proxy. Proxies allow people to pretend they are surfing, accessing a website, etc. from a location which is different from their real one. It turns out people don't really do that willingly, as this interesting post describes. There is a public (but not free...) service on the web that lets you select where you would like to be (i.e. how the site you are trying to access/trick sees you), not clear is where or rather who the proxy computer actually is. The author of the post uncovered the identities of some of them, which turned out to be servers of sizeable companies and organizations, who were reportedly unaware of the "trade" that was going on with the computer systems. The fact that mainly businesses where being "rented" as proxies was also shown by the number of available proxies, which peaked during US (there are the mostly requested proxy locations) business hours.

Last Updated on Tuesday, 12 April 2011 01:50
 

Computational Knowledge Engine

Print PDF

A cool tool that lets you search for things, compute the square root of two, convert from dollars to yen, find the value of Pi, and all in a single text box. That's what I call the "Google principle", functions look extremely streamlined, no unnecessary hassle for the user... type and go, sort of.

And this tool is a sort of google but with a better chance of getting an answer, when there is supposed to be an answer anyway. Though you can ask something like "Ultimate Question of Life, the Universe, and Everything", you will get in reply a quote from one of the books from Douglas Adams' humorous science-fiction novels (like The Hitchhiker's Guide to the Galaxy, The Restaurant at the End of the Universe, ...).

 
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »


Page 1 of 2