In this article, we'll see how to insert rows and columns into your Excel sheet.
So let us see that now I have written some data into some sheet the name of the sheet is insert rows and columns that is the sheet name the file name is Excel VBA that's the data which is given here now if I want to insert rows and columns without the macros how do we do it usually we right-click on this place okay any cell, and then we click on this insert button we get this dialog box it says entire row or entire column which one do you want, so this cell have selected as b4 okay, and I can select as in entire column so row or column will be inserted at this place, so I'll just click on cancel but how do I do it with the help of a macro Sri B macro so let us see that I'll open the VBA macro window okay that's a window which is given here now, so I have this names of all the list these are the sheet names which are given I'll maximize this objects okay and now these are the names of the modules which are given so what I've done is I've created a model insert rows and columns the module name and have written some code here let us see what exactly the code is I have written a sub procedure sub insert row and column the first one has given us range C to C that is dot insert now what is C to C it's nothing but the name of the column so if I say C to see a column will be inserted in this place itself okay next one if you see range one is to one that is given as dot insert one is to 1 mins row number is given as 4 inserts again if you want to insert let's say C to D column okay, so you can insert as C to D and that means 2 columns will be inserted if we want to insert 4 columns you can insert as a 2 D from here a : d so from a : to d : all the columns will be inserted okay that is how you can work on it next is let's see now if I execute those two lines what will happen if I keep my cursor and if I click on this step into now if you observe here C colon C that means a C column will be inserted into this place okay a separate column now if you see a column is inserted this has been shifted to the right-hand side if I want to insert the first row 1 : 1 that is if I click on this place and if you see the first column I mean the first row is inserted here that is one call, but one next is if I want to insert at cell number b5 at cell number b5 I want to insert entire column so range b v dot entire column dot insert so let us see cell number b5 this is Wednesday okay and this place a separate column will be inserted let's see if I click on this step into you see at cell number b5 the entire column has been inserted similarly if I want to insert a row at that cell number b5 right now it is empty b5 is right there empty so entire row will be inserted at this location if I click on the step into now if you observe row number five it's been blank now that means a new row which has been inserted, and finally I will come out of this sub procedure itself right, so these are very simple and easy commands that is inserting rows and columns or if you don't want at specific location you can select these areas also right, so I hope you were able to understand how to insert rows and columns with respect to the cell or without T cell itself that's all for this video
You must be logged in to post a comment.