For inspiration purposes...

nigelandrewfoster

Well-known Member
Joined
May 27, 2009
Messages
747
I have hit a point of understanding with VBA in which things are suddenly to begin to really fall into place. The power and vastness of VBA is just beginning to become apparent. What is the most impressive piece of coding you have seen for VBA for Excel? What did it do? What made it so impressive? What is Excel capable of? I'm seriously considering a career in programming now, and your answers will further inspire me. (This has been happening for a while, and I realised how much I wanted to work in programming last week when I downloaded a ZX81 emulator for my Android phone and played 1K Chess on it! Now that is a staggering achievement!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
These bits of excel are wowing http://excelunusual.com/ though not strictly VBA, although since they don't solve any of my problems the "wow" is limited. Many posts on this site are wow inspiring but not all solve problems that I have.

So for me, any bit of code that completes a required task is impressive, made more so when I find code that does things in an elegant fashion.
This will sound egotistical but, I find some of the stuff that I have accomplished to be impressive, simply because it has saved me or my team, time and grief. Now if I can get to the point where is it elegant, like some of our esteemed members here, that would be something.

Though as you alluded, the wow factor is scalable, I am finding the more I learn the more complex my problems become because I now know I can push beyond what I thought the limits where.

Some around here have pushed the limits way beyond my current horizion but they are also willing to help the rest of us to take the next steps forward. The great thing about this place. Cheers to the helpful. :beerchug:
 
Yes, it's the elegance that holds a deep attraction to me. Last night, I was responding to a query from an Excel newbie, and on my fifth attempt, managed to reduce his 30+ line procedure to just two lines. I cannot describe the satisfaction that this brought me. I'm hooked! Bring on more.... Will check out the website you suggested. Thanks.
 
By the way, what did you mean by 'not strictly VBA'? I guess they use many API calls, and other languages, perhaps?
 
By the way, what did you mean by 'not strictly VBA'? I guess they use many API calls, and other languages, perhaps?


The stuff that I downloaded to look at was very formula and chart based.

http://excelunusual.com/archive/201...ng-model-for-spherical-mirrors-video-preview/

http://excelunusual.com/archive/2011/07/the-melting-snow-castle-video-preview/

http://excelunusual.com/archive/2011/07/a-family-of-speedometers-video-preview/

download the examples, the speedo uses a chart and animates the hand as a graphing elements :eeek:. They are not protected so I tried to pick them apart and was baffled and amazed. I got it conceptually but the execution was WAY-WAY beyond my skill and patience level.
 
Yes, it's the elegance that holds a deep attraction to me. Last night, I was responding to a query from an Excel newbie, and on my fifth attempt, managed to reduce his 30+ line procedure to just two lines. I cannot describe the satisfaction that this brought me. I'm hooked! Bring on more.... Will check out the website you suggested. Thanks.

I have had this type of experiance, it is a great feeling. Must be why so many people here give of there timeto help - its a great high.
 
Here's something that I've always liked. I didn't write it, Daniel Klann did. It's pretty cool. It just replaces the entries in a inputbox with (in this case stars) any password characters you choose. Pretty slick I thought.
Code:
Option Explicit
'PROCEDURE TO MAKE INPUTBOXES SHOW PASSWORD CHARACTERS
'API functions to be used
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long

Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long

Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" _
(ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long

Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long

Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" _
(ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long

Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long

'Constants to be used in our API functions
Private Const EM_SETPASSWORDCHAR = &HCC
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private Const HC_ACTION = 0

Private hHook As Long

Public Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim RetVal
Dim strClassName As String, lngBuffer As Long

If lngCode < HC_ACTION Then
NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
Exit Function
End If

strClassName = String$(256, " ")
lngBuffer = 255

If lngCode = HCBT_ACTIVATE Then 'A window has been activated

RetVal = GetClassName(wParam, strClassName, lngBuffer)

If Left$(strClassName, RetVal) = "#32770" Then 'Class name of the Inputbox

'This changes the edit control so that it displays the password character *.
'You can change the Asc("*") as you please.
SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), &H0
End If

End If

'This line will ensure that any other hooks that may be in place are
'called correctly.
CallNextHookEx hHook, lngCode, wParam, lParam

End Function

Public Function InputBoxDK(Prompt, Optional Title, Optional Default, Optional XPos, _
Optional YPos, Optional HelpFile, Optional Context) As String
Dim lngModHwnd As Long, lngThreadID As Long

lngThreadID = GetCurrentThreadId
lngModHwnd = GetModuleHandle(vbNullString)

hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)

InputBoxDK = InputBox(Prompt, Title, Default, XPos, YPos, HelpFile, Context)
UnhookWindowsHookEx hHook

End Function
 

Forum statistics

Threads
1,222,622
Messages
6,167,137
Members
452,098
Latest member
xel003

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top