• 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.

Need assistance/help with VBA Code

mgesh2002

Member
Hello Ninjas,

Please find attached the excel file. On Row 50, I have two buttons to Add or Delete the primary contact section (Row 41:48).

If I press the "Click to add another Primary Contact" button, then the empty Primary Contact section (Row 41:48) inserted below the first one and If I press the "Click to delete new Primary Contact", then the latest Primary Contact should be deleted.

If you could assist me on writing a VBA code for these two buttons that would be really helpful.

Thanks in advance.

Regards,
Muru
 

Attachments

  • Questionnaire Design_v1.xlsm
    168 KB · Views: 0
Muru

I would use two subroutines like:
Code:
Sub Add_Primary_Contact()
  Sheets("Input (Questioner)").Select
  Rows("49:55").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
 
  Range("B42:M48").Copy
  Range("B49").Select
  ActiveSheet.Paste
  Application.CutCopyMode = False
  Rows("49:49").RowHeight = 7.5
  Range("B51,C51:H51,I51:K51,L51:M51,L53,J53:K53,C53:I53,B53,G55,H55,I55:J55").ClearContents
  Range("F57").Select
End Sub

Code:
Sub Del_Primary_Contact()
  Sheets("Input (Questioner)").Select
  Rows("49:55").Select
  Selection.Delete Shift:=xlUp
  Range("F50").Select
End Sub

See attached file
 

Attachments

  • Questionnaire Design_v1-1.xlsm
    207 KB · Views: 0
Back
Top