Q&A for How to Write a Simple Macro in Microsoft Excel

Return to Full Article

Search
Add New Question
  • Question
    If I have two lines of dates in one cell, how do I delete the first line?
    Community Answer
    Double click on the cell, or click the cell and then F2. Then, delete the part that you don't need. If you want to do this on a large number of cells on the same column, then select the column, click "DATA" on the top menu, click on "Text to Columns," and try the different options to divide the data there. (There are too many to list here.) You can divide by commas, spaces, dashes, periods, etc., or specify the length. Make sure the columns on the right are empty; the divided data will split into those columns.
  • Question
    While recording a macro, will it record something I want done outside of Excel, such as opening up a website and clicking on things in that website?
    Community Answer
    No. The macro program in Excel is limited to Excel. Once you use an outside program, Excel will be unable to record what you are doing.
  • Question
    How do I secure files in Excel?
    Community Answer
    Click the Microsoft Office button, point to Prepare, and then click Encrypt Document. In the Password box, type a password, and then click OK. In the Reenter Password box, type the password again, and then click OK. To save the password, save the file.
  • Question
    How do I write a micro to clear out cells?
    Community Answer
    First, open an excel working book. Then enter data on Sheet 1 at A1:C10. Press Alt+F10 to open VBA Editor. Insert a module for insert menu. Copy the above code and paste in the code window. Save the file as a macro enabled working and press F5 to run it.
  • Question
    What do I do if my macros are disabled in MS Excel?
    Community Answer
    If you are using a PC from work, that may be a safety feature from your IT department to prevent malicious code from affecting your PC or your network, and only they can modify it. I'd recommend getting in touch with the IT department first.
  • Question
    How do I write a macro so that instead of the macro going to a specific cell it needs to go to a blank cell in a specific column?
    Community Answer
    Recorded macro may not capture logic to identify the blank cells as it capture all cursor movements and may end up selecting the specific cells only. However we may amend the part of code to get the desired result. In the above code we may replace ActiveCell with Range("C65000").End(xlUp).Offset(1, 0) to get such result. Range("C65000").End(xlUp).Offset(1, 0) will be interpreted by the macro recorder as below: 1. Place the cursor on “C65000” assuming we wouldn’t have data beyond that point. 2. then moves upward as we would expect by Ctrl + Home and select the last filled row in that column. 3. and finally offset one row down to find the next available row.
Ask a Question

      Return to Full Article