You are here:

Excel/insert an additional row if A3>B2

Advertisement


Question
Hi Jan,

How do I do a macro / VBA to insert an additional row if A3>B2?

How do I add this into my excel? Do I go to Macros > View Macros > Create a new Macro > ? Is this too considered VBA ?

Answer
Hi Lee,

Yes, a macro is written in VBA.

You open the VBA editor (Alt+F11).
Then insert a module into the workbook where you want to store the macro.
Then you enter something like:

Sub AddaRowOrNot()
   If Range("A3").Value > Range("B2").Value Then
       'Inserts a row above row 3
       Range("A3").EntireRow.Insert
   End If
End Sub
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Jan Karel Pieterse

Expertise

Excel and Excel/VBA questions

Experience

Excel MVP

Organizations
Self employed Excel developer

Education/Credentials
Bachelor in Chemical Engineering

Awards and Honors
Microsoft MVP award since 2002

Past/Present Clients
Shell, Fortis bank, ABN-AMRO bank, Morgan Stanley, ...

©2016 About.com. All rights reserved.