VBA Macro dosn't appear in new workbooks

%3CLINGO-SUB%20id%3D%22lingo-sub-2356290%22%20slang%3D%22en-US%22%3EVBA%20Macro%20dosn't%20appear%20in%20new%20workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2356290%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20recorded%20a%20simple%20macro%20and%20Stored%20it%20in%20the%20Personal%20Macro%20Workbook.%26nbsp%3B%20When%20I%20tried%20to%20run%20it%20on%20another%20new%20file%2C%20the%20macro%20was%20not%20present%3F%20Any%20help%20would%20be%20appreciated.%3C%2FP%3E%3CP%3ERye%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2356290%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2356905%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Macro%20dosn't%20appear%20in%20new%20workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2356905%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1034179%22%20target%3D%22_blank%22%3E%40RyeTo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPress%20Alt%2BF11%20to%20activate%20the%20Visual%20Basic%20Editor.%3C%2FP%3E%0A%3CP%3EExpand%20VBAProject%20(PERSONAL.XLSB)%20in%20the%20navigation%20pane%20on%20the%20left%2C%20then%20expand%20Modules%20(if%20present).%3C%2FP%3E%0A%3CP%3EDouble-click%20each%20of%20the%20items%20under%20the%20Modules%20heading.%3C%2FP%3E%0A%3CP%3EDo%20you%20see%20the%20macro%20that%20you%20recorded%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2357149%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Macro%20dosn't%20appear%20in%20new%20workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2357149%22%20slang%3D%22en-US%22%3EHi%20Hans%2C%20hope%20you're%20well.%20Everyday%20I%20download%20.cvs%20file%20(each%20with%20a%20new%20random%20name)%2C%20do%20some%20macro%20changes%20and%20save%20it%20as%20DATA.xlsm.%20This%20is%20what%20I've%20done%3A%3CBR%20%2F%3Edownload%3A%20xyz259712.cvs%20(everyday%20is%20a%20different%20name)%3CBR%20%2F%3Echange%20tab%20name%3A%20Raw%20Data%3CBR%20%2F%3Esave%20as%3A%20DATA.xlsm%3CBR%20%2F%3Erecord%20macro%3A%20name%3A%20DATA%2C%20Ctl%2BShift%2BD%2C%20Store%20Macro%20in%3A%20Personal%20Macro%20Workbook%3CBR%20%2F%3Eselect%20entire%20sheet%3A%20sort%20A%20to%20Z%3CBR%20%2F%3Eselect%20columns%20A%2CF%2C%20and%20H%2C%20colour%20Yellow%3CBR%20%2F%3Eselect%20Row1%2C%20Bold%3CBR%20%2F%3Estop%20Recording%3CBR%20%2F%3Esame%20file.%3CBR%20%2F%3ESo%20now%20I%20wish%20to%3A%3CBR%20%2F%3E1.%20download%20and%20new%20random%20.cvs%20file%3CBR%20%2F%3E2.%20have%20the%20macro%20do%20the%20minor%20changes%20above%3CBR%20%2F%3E3.%20Update%20the%20DATA%20file.%3CBR%20%2F%3ESeems%20simple%20but%20have%20not%20been%20able%20to%20do%20it%3F%3CBR%20%2F%3EThanks%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2357241%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Macro%20dosn't%20appear%20in%20new%20workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2357241%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1034179%22%20target%3D%22_blank%22%3E%40RyeTo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESince%20you%20want%20to%20be%20able%20to%20use%20the%20macro%20for%20multiple%20workbooks%2C%20you%20should%20store%20it%20in%20your%20personal%20macro%20workbook%20PERSONAL.XLSB.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fcopy-your-macros-to-a-personal-macro-workbook-aa439b90-f836-4381-97f0-6e4c3f5ee566%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECopy%20your%20macros%20to%20a%20Personal%20Macro%20Workbook%3C%2FA%3E%20for%20instructions%20on%20how%20to%20do%20that.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2357667%22%20slang%3D%22en-US%22%3ERe%3A%20VBA%20Macro%20dosn't%20appear%20in%20new%20workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2357667%22%20slang%3D%22en-US%22%3EI%20finally%20got%20the%20macro%20to%20run.%3CBR%20%2F%3EAfter%20downloading%20the%20.csv%20file%20I%20needed%20to%20rename%20the%20tab%20to%20%22Raw%20Data%22%20and%20save%20it%20as%20DATA.XLSM%20before%20running%20the%20macro.%3CBR%20%2F%3EAny%20way%20to%20run%20macro%20with%20the%20.cvs%20file%20directly%20without%20renaming%20the%20tab%20and%20saving%20to%20DATA.XLSM%20manually%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

I recorded a simple macro and Stored it in the Personal Macro Workbook.  When I tried to run it on another new file, the macro was not present? Any help would be appreciated.

Rye

 

6 Replies

@RyeTo 

Press Alt+F11 to activate the Visual Basic Editor.

Expand VBAProject (PERSONAL.XLSB) in the navigation pane on the left, then expand Modules (if present).

Double-click each of the items under the Modules heading.

Do you see the macro that you recorded?

Hi Hans, hope you're well. Everyday I download .cvs file (each with a new random name), do some macro changes and save it as DATA.xlsm. This is what I've done:
download: xyz259712.cvs (everyday is a different name)
change tab name: Raw Data
save as: DATA.xlsm
record macro: name: DATA, Ctl+Shift+D, Store Macro in: Personal Macro Workbook
select entire sheet: sort A to Z
select columns A,F, and H, colour Yellow
select Row1, Bold
stop Recording
same file.
So now I wish to:
1. download and new random .cvs file
2. have the macro do the minor changes above
3. Update the DATA file.
Seems simple but have not been able to do it?
Thanks

@RyeTo 

Since you want to be able to use the macro for multiple workbooks, you should store it in your personal macro workbook PERSONAL.XLSB.

 

See Copy your macros to a Personal Macro Workbook for instructions on how to do that.

I finally got the macro to run.
After downloading the .csv file I needed to rename the tab to "Raw Data" and save it as DATA.XLSM before running the macro.
Any way to run macro with the .cvs file directly without renaming the tab and saving to DATA.XLSM manually?


@RyeTo 

Here is a macro; you can tweak it for your purposes of course. I have added comments above most lines.

Sub ProcessCSV()
    Dim strFile As String
    Dim wbk As Workbook
    Dim wsh As Worksheet
    ' Prompt user for csv file
    strFile = Application.GetOpenFilename(FileFilter:="CSV files (*.csv),*.csv")
    ' Get out if no file selected
    If strFile = "False" Then
        Beep
        Exit Sub
    End If
    ' Speed up execution by hiding what we're doing
    Application.ScreenUpdating = False
    ' Open the csv file
    Set wbk = Workbooks.Open(Filename:=strFile)
    ' Reference to the first (and only) sheet
    Set wsh = wbk.Worksheets(1)
    ' Optional: rename tab
    wsh.Name = "Raw Data"
    ' Sort on column A
    wsh.UsedRange.Sort Key1:=wsh.Range("A1")
    ' Color columns A, F and H
    Intersect(wsh.UsedRange, wsh.Range("A:A,F:F,H:H")).Interior.Color = vbYellow
    ' Make row 1 bold
    Intersect(wsh.UsedRange, wsh.Range("1:1")).Font.Bold = True
    ' Save as a .xlsm workbook
    wbk.SaveAs Filename:=wbk.Path & "\DATA.xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
    ' Optional: close the workbook
    wbk.Close
    ' Update the screen again
    Application.ScreenUpdating = True
End Sub
Thanks Hans, I will try.
Good weekend.