I was just going to PM you. I need your help. Sorry I didnt mean to cross post.
I was just going to PM you. I need your help. Sorry I didnt mean to cross post.
Still no sign of the link ??
Also need to add to the other forum otherwise it will be locked!!
VBA Noob
_________________________________________
![]()
![]()
Credo Elvem ipsum etian vivere
_________________________________________
A message for cross posters
Please remember to wrap code.
Forum Rules
Please add to your signature if you found this link helpful. Excel links !!!
Sorry about the cross post. I didnt trully understand what I had done wrong until now. I can totally appriciate this rule. My cross post is at http://www.ozgrid.com/forum/showthread.php?t=86445
They wont let me post this link there until after 24 hours and I will do just that tomorow when I return.
Thanks VBA Noob for pointing that issue out.
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".
Sincerely,![]()
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
Leith Ross
Leith,
Thanks so much for your help. I think I have steped into another world of macros though. When I open the workbook the macro does what I need but I dont see it in the macro list. Is this running in the background somehow??? How do I enter this macro into my workbook? Also, I am not sure what to change so that it copy's everything except values such as the qty. I trully appriciate your time and help on this one.
Thanks
RAH
Hello RAH,
The macro is attached to the worksheet to the by its Worksheet_Change event procedure. Whenever a cell's value is changed, the macro runs. I have made a change to blank the quantity when the line is copied. The change is marked in blue.
How to Save a Worksheet Event Macro![]()
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 Cells(R, "C").Value = "" End If Application.EnableEvents = True End Sub
1. Copy the macro using CTRL+C keys.
2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
3. Left Click on View Code in the pop up menu.
4. Paste the macro code using CTRL+V
5. Save the macro in your Workbook using CTRL+S
Sincerely,
Leith ross
Thats fantastic... I trully appriciate the help. Thanks so much!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks