Simple Error Checking

  • Thread starter Thread starter AndyR
  • Start date Start date
A

AndyR

Hi

I have several macros associated with a worksheet, these macro's
perform various simple functions, eg. insert rows, move rows up/down
etc.

What I would like is to know how to word error checking so that

Rows cannot be moved above Row 7. (Rows 1-6 contain headings so I do
not want a row 7 and Row 6 switched by running this macro.
Rows 1-6 cannot deleted.

Something along the lines of "If Activecell < A7 Then ErrorMessage"
etc.

Any ideas?

Apologies if not clear.

Regards
Andy
 
Sub Top6Rows()
If ActiveCell.Row < 7 Then
MsgBox ("Not permitted")
End If
End Sub

An easier alternative might be to unlock rows 6 &below, then protect the
worksheet.
 
Sub SwapRows(FirstRow as long, SecondRow as long)
if firstrow<=6 or secondrow<=6 then
msgbox "Can't move title rows!"
exit sub
end if
'your code to swap the rows
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top