• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

To insert row

vinodh

New Member
hi,
i m practicing financial planning, and i just want an excel sheet where i can add the details of my clients.
i tried a macro where i can insert a row in a table if i wanted ve more values to be added
eg: lets say client has dependents two sons and his mom and dad, four dependents
the macro tat i tried is inserting a row but its inserting rows in a same cell , example in the macro i gave A5 as the range to insert a row and its inserting the rows in A5, i want the rows to be inserted beneath the added row each and everytime when i add a new row...
can you please help me, can some give me a code for it
regards
vinodh
 

Attachments

Hi Vinodh ,

I am not able to understand what you want to do.

Can you enter at least 5 rows of data , and then describe what you wish to do ? What should happen each time the New Row button is clicked ?

Narayan
 
Welcome to Chandoo.org forums!

Replace your old code with this one and see if it works as you need. Be sure to test it on a backup.
Code:
Private Sub CommandButton1_Click()
Dim intRows As Integer
Dim r As Range

intRows = Application.InputBox(Prompt:="Specify number of rows to be inserted!", Title:="INSERT ROW", Type:=1)
If intRows < 0 Then Exit Sub

Set r = Application.InputBox(Prompt:="Select the top cell!", Title:="SPECIFY CELL", Type:=8)
If r Is Nothing Then Exit Sub

r.Offset(1, 0).Resize(intRows, 1).EntireRow.Insert xlDown

End Sub

Private Sub CommandButton2_Click()
Dim r As Range
Dim intResult As Integer

Set r = Application.InputBox(Prompt:="Select the rows to delete!", Title:="DELETE ROWS", Type:=8)
If r Is Nothing Then Exit Sub

intResult = MsgBox("Do you want to delete this data?", vbYesNo)

If intResult = 6 Then
    r.EntireRow.Delete
End If

End Sub
 
Hi Narayank991,
in the excel sheet that i ve attached, if you click the Insert button it ll insert the row in cell A5, once i entered the values in the cell A5, again to add a new row if i click the insert button the new row inserted in the cell A5 again shifting the current row to the next Cell that is A6, so the value that i entered goes down and i get a blank row before that which is not right, i need the new row to be inserted next to the cell A5 that is A6 like so on..its should enter the rows next to the each new after the value has been filled
 
Hi Shrivallabha,
thanks for your help i think I could manage with the code that you ve sent.
thanks a lot for your help.
 
Hi shrivallabha,
your code works great but there's a problem in that.
i ll attach the sheet pls kindly help in that.
i ve merged some cell and i ve created the table, once i clicked the insert button the new row that has been inserted doesnt take the table borders as i ve bordered for the table . its not creating a new row with the actual table borders its just giving borders to all the cells,
kindly help me
regards
 

Attachments

Hi Shrivallabha,
my senior has asked me to do like that, perhaps i'll discuss with my senior about it and lemme try to create table without merging cells.
regards,
 
Hi, vinodh!
Merging cells maybe look attractive but working with it isn't easy. An argument that you could use when debating with your boss is that of replacing the usage of merged cells by center in the selection, which visually it's the same and doesn't make things harder when referencing cells.
Regards!
 
Hi SirJB7,
ya your correct, I've explained to my boss and he is kinda ok with what i explained..I told the same thing what you said to me now...thanx a lot for your reply
regards
 
Hi, vinodh!
Glad you could make your boss change his mind. But I'm bad news: those are the worst bosses; it'd be more difficult to get rid of them (aka make them got fired) than those who don't accept reasonable suggestions and are open to hear about improvements... so you'll have to work harder with the saw. ;)
Thanks for your feedback and welcome back whenever needed or wanted.
Regards!
 
Hi SirJB7,
ya sure i ll do that....thank you so much.
but he cant be fired coz he is the MD of the company.:(:mad::):)
regards
 
@vinodh
Hi!
Bill Gates only president and not CEO at Microsoft, Mike Lazzaridis even founder not anymore at Blackberry's board, Michael Dell about sinking Dell again ... and the list follows. So neither worry nor hurry, just sharpen the saw. :p
And don't forget to make the best alliances that you could... that are those in which you find someone to blame... just in case of a new Titanic.
Regards!
 
Back
Top