Articles

work smarter with VBA

"We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths."

- Walt Disney

01/06/2017
Basse

Send sheet as .pdf

Sub button_click()   Dim DataSti As String Dim Filnavn As String Dim objFolders As Object Set objFolders = CreateObject(“WScript.Shell”).SpecialFolders Dim OutlookPrg As Object Dim OutlookMail As Object Set OutlookPrg = CreateObject(“Outlook.Application”) Set OutlookMail = OutlookPrg.CreateItem(0)   DataPath = objFolders(“desktop”) & Application.PathSeparator Filnavn = Worksheets(“Sheet1”).Range(“D5”).Text  & “.pdf”   ActiveSheet.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=DataPath & Filnavn, _ Quality:=xlQualityStandard,

22/05/2017
Basse

a small homemade formula

This formula i use in my work quite a lot. Please note, that if you want to call the function in VBA, then you have to have the function in a module and not in a regular sheet. It took me a while to figure that one out 🙂  when i got started. I receive

13/05/2017
Basse

“automatic” running subs

I sometimes get annoyed that i have to manually update Pivot tables and the likes, therefore i hope these can help other people as well. If there is any i have forgotten please comment, i’m still a bit new in the VBA world.   Private sub Worksheet_Deactivate() ‘ what to do when you leave a

01/05/2017
Basse

Force users to save spreadsheet with active macroes.

 –>  2 steps, a friend of mine suggested that i put a save as button in the file, that activates the function button F12 (Save as) If you add the code below in VBA you’ll make sure the file is saved as a .xlsm Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim txtFileName As String