Stop Recording<\/strong>.<\/li>\n<\/ol>\n\n\n\nLet\u2019s take a look at the generated code:<\/p>\n\n\n\n
Sub Absolute()\n'\n' Absolute Macro\n'\n Range(\"A1\").Select\n ActiveCell.FormulaR1C1 = \"Mon\"\n Range(\"A2\").Select\n ActiveCell.FormulaR1C1 = \"Tue\"\n Range(\"A3\").Select\nActiveCell.FormulaR1C1 = \"Wed\"\nRange(\"A1\").Select\nEnd Sub<\/pre>\n\n\n\nYou can select any cell, but when you execute this macro you will always get \u201eMon\u201d in cell A1,<\/strong> \u201eTue\u201d in cell A2,<\/strong> and \u201eWed\u201d in cell A3.<\/strong><\/p>\n\n\n\nRelative Macro recording<\/h3>\n\n\n\n Let\u2019s see how the relative macro recording works.<\/p>\n\n\n\n
\nActivate any cell.<\/li>\n\n\n\n Make sure that DEVELOPER >> Code >> Use Relative References<\/strong> is highlighted.<\/li>\n\n\n\nGo to DEVELOPER >> Code >> Record Macro<\/strong> and name it \u201eRelative\u201d. Click OK to start recording.<\/li>\n\n\n\nType \u201eMon\u201d.<\/li>\n\n\n\n Select the cell below and type \u201eTue\u201d.<\/li>\n\n\n\n Select the cell below and type \u201eWed\u201d.<\/li>\n\n\n\n Click the cell where you typed \u201eMon\u201d.<\/li>\n\n\n\n Click Stop Recording<\/strong>.<\/li>\n<\/ol>\n\n\n\nThis is the code generated by VBA:<\/p>\n\n\n\n
Sub Relative()\n'\n' Relative Macro\n'\n ActiveCell.FormulaR1C1 = \"Mon\"\n ActiveCell.Offset(1, 0).Range(\"A1\").Select\n ActiveCell.FormulaR1C1 = \"Tue\"\n ActiveCell.Offset(1, 0).Range(\"A1\").Select\n ActiveCell.FormulaR1C1 = \"Wed\"\n ActiveCell.Offset(-2, 0).Range(\"A1\").Select\nEnd Sub<\/pre>\n\n\n\nLine 5.<\/strong><\/p>\n\n\n\nIf you execute this macro in cell C5<\/strong>, Excel will insert \u201eMon\u201d inside the active cell (C5).<\/strong><\/p>\n\n\n\nLine 6.<\/strong><\/p>\n\n\n\nVBA moves the active cell one position below- to cell C6.<\/strong><\/p>\n\n\n\nLines 10. <\/strong><\/p>\n\n\n\nThe active cell is moved up by two cells, to cell C5.<\/strong><\/p>\n\n\n\n\nIf you didn\u2019t start with cell A1 as a reference, it may seem strange that Excel generated such code. This is just the way that the macro recorder works.<\/p>\nNOTICE<\/cite><\/blockquote>\n\n\n\nExcel 365 Update<\/h2>\n\n\n\n\nLimited Visual Update:<\/strong> While the core functionality remains similar, Excel 365 offers a slightly modernized look<\/strong> for the Macro Recorder interface.<\/li>\n\n\n\nRecording Still Straightforward:<\/strong> The process of recording macros hasn’t changed significantly. Users familiar with Excel 2016 can easily transition to recording macros in Excel 365.<\/li>\n\n\n\nSecurity Enhancements:<\/strong> Excel 365 implements stricter security measures around macros. Macro settings might need to be adjusted to allow the running of recorded macros compared to Excel 2016.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"A popular method to create a macro is to use the Macro Recorder. When you use this tool, you show Excel (by clicking on…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[188],"yoast_head":"\n
The Macro Recorder<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n