Posts

Showing posts with the label VBA macro

How to auto run a VBA macro whenever Ms Excel or Ms Project starts

This is how you can set the VB macro to auto run whenever Ms Excel or Ms Project starts. To do this, rename your macro name to "Auto_Open". Yes! it's as simple as that. References, Sources and Credits: Running a macro when Excel starts

How to save file and automatically overwrite an existing file without prompt in VBA macro

This is how to run the FileSaveAs command in VBA macro which is commonly used in Ms Excel or Ms Project without having the application prompt for overwriting and existing file. The idea is to temporarily setting the object "Application.DisplaysAlerts" to false and then set it back to true after the file save. Example: Application.DisplayAlerts = False FileSaveAs command Application.DisplayAlerts = True

How to save as a new file extension using the same current filename in VBA macro

This is how you can save as a new file with a different file extension but the you would like to use back the same file name as the current file you are saving from. This is a VBA macro code for Ms Excel, Ms Project or any other Ms Office product that uses VBA macro for automation. By using the object "ThisProject.Name", assign it to a variable and use the variable in the "FileSaveAs" command file path parameter. Example: Dim FileName As String FileName = ThisProject.Name FileSaveAs Name:="\path" & FileName & ".csv", FormatID:="MSProject.CSV", map:="exportCSV_map"

Autofill empty cells with content from the first cell above the empty cells in Microsoft Excel

Image
Non Macro Solution Select the first cell that have the content that need to be paste to the empty cells. Scroll down to the last empty cells below the first cell that needed to be fill. Hold shift and select the last cell. Ctrl + D Macro Solution Sub fill_cells()     Selection.SpecialCells(xlCellTypeBlanks).Select     Selection.FormulaR1C1 = "=R[-1]C"     Range(Cells(1, 1), Selection.SpecialCells(xlCellTypeLastCell)).Select     Selection.Copy     Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False End Sub References: My Excel Pages -- David McRitchie (Fill The Empty Cells)