Results 1 to 10 of 10

Custom Order Template VBA or Macro

Threaded View

  1. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello RAH,

    Here is the macro that has been added to your original workbook. The Validation drop down list contains 2 additional entries: a blank and "Add a Line".
    Private Sub Worksheet_Change(ByVal Target As Range)
    
      Dim LastCol As Long
      Dim R As Long
      Dim vt As Long
      
        On Error Resume Next
          vt = Target.Validation.Type
          If Err.Number = 1004 Then
             Err.Clear
          End If
        On Error GoTo 0
        
        Application.EnableEvents = False
        
          R = Target.Row
          With ActiveSheet.UsedRange
            LastCol = .Columns.Count + .Column - 1
          End With
          
          If vt = xlValidateList And Cells(R, "A") = "Add a Line" Then
            Target.Offset(1, 0).EntireRow.Insert Shift:=xlDown
            Range(Cells(R, "B"), Cells(R + 1, LastCol)).FillDown
          End If
          
        Application.EnableEvents = True
    
    End Sub
    Sincerely,
    Leith Ross
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1