Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
i have an excel 2002 workbook with the following VBA...
Sub InsertActivity() Dim r As Long Dim Start As Long Dim answer As Long answer = MsgBox("Are you sure that you want to INSERT an activity here?", vbYesNo) If answer < vbYes Then Exit Sub Application.ScreenUpdating = False ActiveSheet.Unprotect Password:="flow" r = ActiveCell.Row Start = Cells(r, "A").Select ActiveCell.Range("A1:AU1").Select Selection.Copy Selection.Insert Shift:=xlDown Application.CutCopyMode = False Start = Cells(r, "A").Select ActiveCell.Offset(0, 1).Range("A1:AU1").Select Selection.ClearContents Start = Cells(r, "D").Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, Password:="flow" Application.ScreenUpdating = True End Sub it is for a form, and the macro allows the user to insert a row in the body of the form in case a row needs to be added. It works great, except if the active row is in the header part of the form, and not the body of the form, where you would normally insert a line. If you absent-minded forget that the active cell is in the header, the result is a 2nd header of several lines being inserted. Several lines are inserted because there are some merged cells in the header. What I would like is to be able to modify this macro so if the active cell is anywhere in the header rows 1 -19, the macro will inform you that you cannot insert a row there, then exit the macro. I have put in the warning message box, but it has been overlooked before, including by myself even! Thank you for your help as always, Tonso |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Feb 11, 1:58 pm, "Don Guillett" wrote:
if activecell.row<10 then exit sub You should also remove all selections as they are rarely necessary or desirable. -- Don Guillett SalesAid Software "Tonso" wrote in message ps.com... i have an excel 2002 workbook with the following VBA... Sub InsertActivity() Dim r As Long Dim Start As Long Dim answer As Long answer = MsgBox("Are you sure that you want to INSERT an activity here?", vbYesNo) If answer < vbYes Then Exit Sub Application.ScreenUpdating = False ActiveSheet.Unprotect Password:="flow" r = ActiveCell.Row Start = Cells(r, "A").Select ActiveCell.Range("A1:AU1").Select Selection.Copy Selection.Insert Shift:=xlDown Application.CutCopyMode = False Start = Cells(r, "A").Select ActiveCell.Offset(0, 1).Range("A1:AU1").Select Selection.ClearContents Start = Cells(r, "D").Select ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, Password:="flow" Application.ScreenUpdating = True End Sub it is for a form, and the macro allows the user to insert a row in the body of the form in case a row needs to be added. It works great, except if the active row is in the header part of the form, and not the body of the form, where you would normally insert a line. If you absent-minded forget that the active cell is in the header, the result is a 2nd header of several lines being inserted. Several lines are inserted because there are some merged cells in the header. What I would like is to be able to modify this macro so if the active cell is anywhere in the header rows 1 -19, the macro will inform you that you cannot insert a row there, then exit the macro. I have put in the warning message box, but it has been overlooked before, including by myself even! Thank you for your help as always, Tonso- Hide quoted text - - Show quoted text - Thanks ever so much! That works perfect! Tonso |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto Rename Excel Sheets in Workbook | Excel Worksheet Functions | |||
macro | Excel Discussion (Misc queries) | |||
Sum up columns in different sheet with error check | Excel Discussion (Misc queries) | |||
HELP!! Unhide Sheet with Macro and focus on other sheet | Excel Discussion (Misc queries) | |||
Selecting Last Sheet | Excel Worksheet Functions |