wtorek, 22 września 2015

RAD in Excel? Excel Framework, Parent Class Builder

Following the examples below one can develop a tool in Excel that generates the templates of classes with implemented encapsulation and collections for the specified data fields

 - Interesting article and tool that generates templates with parent-child relationship between classes in VBA, ie. single item class and its collection class. http://www.experts-exchange.com/articles/3802/Parent-Class-Builder-Add-In-for-Microsoft-Excel.html

- Another interesting example: Excel VBA Framework - an Excel tool that generates the classes for the fields entered in an Excel table.https://code.google.com/p/excel-vba-framework/downloads/list


Autofill a column next to my pasted data.

After I paste new rows into my data I need to fill down some formulas in an adjacent column. What if I would like to make it automatic? I came up so far with this code (in Worksheet module). I paste in my data to columns A through I and the formulas to be pulled down are in columns J through R:
Private Sub Worksheet_Change(ByVal Target As Range)

'Declare Variables
Dim FR As Long, LR As Long

Application.EnableEvents = False
Application.ScreenUpdating = False

'Find first and last row
FR = Sheets("Output3").Cells(Rows.Count, "J").End(xlUp).Row
LR = Sheets("Output3").Cells(Rows.Count, "A").End(xlUp).Row

If FR = LR Then Exit Sub

'Autofill
Range("J" & FR & ":" & "R" & FR).AutoFill Destination:=Range("J" & FR & ":" & "R" & LR)

Application.EnableEvents = True
Application.ScreenUpdating = True
   

piątek, 18 września 2015

Je fik stres :-)

Świetna komedia o dialogu międzykulturowym, stereotypach i resocjalizacji. "Jabłka Adama"

Coffee break... Et si tu n'existais pas...

Kiedyś nie wiedziałem o czym jest, byłem jeszcze w przedszkolu i kręciłem gałką słuchając egzotycznych dźwięków i tajemniczego szumu. Na średnich falach stare radio dziadka z magicznym okiem. I usłyszałem tę piosenkę i akurat ją zapamiętałem. ...Jeśli nie istniałabyś, to wiem, że też nie istniałbym patrząc jak smutny dzień, szary dzień...

Daily struggles with VBA/ACE SQL report in Excel

1. It does not copy down formulas that I paste in when I need it. On another occasion it does copy down the formulas against my will.


Application.AutoCorrect.AutoFillFormulasInLists = False 'or true if needed
It must be inserted just before the function that pastes in the formula into my listobject.table.

http://www.mrexcel.com/forum/excel-questions/580576-prevent-autofill-formulas-excel-tables-w-visual-basic-applications.html

2. The ACE SQL query execution results in column that is considered as text. I can live with that. But I must order it as numbers:


SORT BY IIf([Fieldname] Is Null, 0, Val([Fieldname]))
https://support.office.com/en-au/article/Sort-records-on-numeric-values-stored-in-a-text-field-502a36c4-2b6e-4453-91b6-7e842d234157 
3. I need my query to be iterated as many times as there are unique values in Excel. So far I found a discussion here: http://stackoverflow.com/questions/1676068/count-unique-values-in-excel
and an Excel formula here http://www.excel-easy.com/examples/count-unique-values.html 

4. Finally, I need to print out my report to pdf and under my table which spreads on multiple pages I need to include an extended description. My Table's column headings are repeating on each page, but I do not want to repeat it on my last page.

 I found two interesting solutions: Printing two sheets to one pdf - in the second sheet I am inserting all my caveats and interpretations to the report: http://stackoverflow.com/questions/14404650/save-multiple-sheets-to-pdf 

Here is a solution with a dynamic last row. It moves in relation to the last page division. http://stackoverflow.com/questions/28950832/in-excel-how-do-i-add-a-footer-to-the-last-page-only

I also need to check if the pdf file is open or not in the case I need to print it again under the same name:
http://stackoverflow.com/questions/25714915/check-if-a-certain-pdf-file-is-open-and-close-it