Inserting rows syntax + row #'ing code in protected sheet?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: StargateFanFromWork (NoJunk_at_NoJunkMail.com)
Date: 07/05/04


Date: Mon, 5 Jul 2004 10:44:20 -0400

Good morning! <g>

The syntax to put basically at beginning and end of a macro that's assigned
to a button to allow it to work in a protected sheet works just great! I'm
testing it out here as I work. The code, courtesy of Dave Peterson, is:

    With ActiveSheet
        .Unprotect
        (my code goes here)
        .Protect
    End With

But, as always seems to be the case, I've run into a particular snag. I
didn't realize that the insert function is gone once a sheet is protected
<g>. So we can't insert new rows to accommodate new data once it's
protected.

Just as an fyi, the rows are set up with conditional formatting so that
there is a light yellow fill on odd or even rows (can't remember which, but
one of those). And in column A I have the automatic row numbering syntax
"=ROW()-1". Thank goodness nothing more complicated than that! <g>

Anywho, I've thought and thought just what would be easiest way to do this
because I'm just no good at figuring out VB code. I don't even know where
to go to get syntax other than these ngs as I've had no success online when
searching for VB coding, so it would be like pulling magic out of thin air
for me. So to keep it simple, perhaps I can create a button on the sheet
that says "insert row" whose function would be to pull up an insert row
dialogue box? I could plug in the unprotect/protect code there for it at
the appropriate spots to make it work. I suppose user could be prompted
with a message box to go to next empty row in the print area? Or perhaps
there's a better way?

Of course, there is the option, I suppose, of just making that button and
then assigning a message box macro to it to say "unprotect the sheet to
insert rows, then protect again" if worse came to worst, but I feel that
would defeat the purpose! <g> And I may not know a lot, but there's plenty
of people who always know less, too! <g> I'd like to make it as easy as
possible for my successor.

<sigh> They want us clerks to perform miracles, yet not give us the tools!
Wish they'd send me on VB training, but nothing can ever be justified when
you're a contract worker! <g> Where would I be without this ng??

Thanks so much.



Relevant Pages

  • Re: Checkbox for protection
    ... it'll unprotect the sheet ... Sub ProtectNHideFormulas() ... assigning a macro and when i ... > checked it it would protect the sheet, but when i unchecked it it did ...
    (microsoft.public.excel.newusers)
  • Re: Declaring Offset as a variable
    ... how would you handle a calculation where 3 variables ... of the corresponding row in the 1st sheet are copied to the second. ... where the variables dstNotebk etc. are declared as constants (e.g. const ... I'd like to neaten it up, for example allowing a syntax like ...
    (microsoft.public.excel.programming)
  • Re: Dim mySheet As New Worksheet
    ... Just saying sometimes it's better not to read too much the details and choose the global point of view for the opening it brings. ... I forgot words and look at ideas only: the syntax was juged "not enought to do the job" because there's not the same level between sheets and strings and we do not want people to forgot this difference. ... vba doesn't expect this kind of object after new) here comes my answer. ... house versus unit so "dim as sheet" does not mean the construct of the house... ...
    (microsoft.public.excel.programming)
  • RE: Can I use a formula in place of OffsetRows?
    ... That solved the syntax issue. ... Based on the Month and ActiveCell.Row on Sheet 1, I want to copy cell data ...
    (microsoft.public.excel.misc)
  • RE: User Defined Function and VLookUP
    ... data is all on the same Sheet. ... "Jacob Skaria" wrote: ... TableData through in the proper syntax. ... use the VLookup Function within the USD. ...
    (microsoft.public.excel.worksheet.functions)