+ Reply to Thread
Results 1 to 3 of 3

Macro

  1. #1
    Frank
    Guest

    Macro

    I need to protect this sheet and tried the
    ActiveSheet.Unprotect(at begining) and ActiveSheet.Protect
    (at end) and it did not work?

    I also wanted to eliminate the first prompt by making the
    first Default any number other than zero?

    Thank you for any assistance you can give.


    Dim vResult1 As Variant
    Dim vResult2 As Variant
    vResult1 = Application.InputBox( _
    Prompt:="Enter Row Number to Replace", _
    Default:=20, _
    Title:="Replacer", _
    Type:=1)
    If vResult1 = False Then Exit Sub 'user cancelled
    vResult2 = Application.InputBox( _
    Prompt:="Enter Replacement Row Number", _
    Default:=21, _
    Title:="Replacer", _
    Type:=1)
    If vResult2 = False Then Exit Sub 'user cancelled
    With Range
    ("A3:AF3,B7:AC7,B11:AF11,B15:AE15,B19:AF19,B23:AE23,B27:AF2
    7,B31:AF31," & _
    "B35:AE35,B39:AF39,B43:AE43,B47:AF47")

    .Replace _
    What:=vResult1, _
    Replacement:=vResult2, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    MatchCase:=False

    End With
    End Sub




  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Not sure if this will help, but at the end, instead of just Protect, try:

    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

  3. #3
    Dave Peterson
    Guest

    Re: Macro

    Your thread got stolen.

    But you have a reply at your other post in .misc.

    Frank wrote:
    >
    > I need to protect this sheet and tried the
    > ActiveSheet.Unprotect(at begining) and ActiveSheet.Protect
    > (at end) and it did not work?
    >
    > I also wanted to eliminate the first prompt by making the
    > first Default any number other than zero?
    >
    > Thank you for any assistance you can give.
    >
    > Dim vResult1 As Variant
    > Dim vResult2 As Variant
    > vResult1 = Application.InputBox( _
    > Prompt:="Enter Row Number to Replace", _
    > Default:=20, _
    > Title:="Replacer", _
    > Type:=1)
    > If vResult1 = False Then Exit Sub 'user cancelled
    > vResult2 = Application.InputBox( _
    > Prompt:="Enter Replacement Row Number", _
    > Default:=21, _
    > Title:="Replacer", _
    > Type:=1)
    > If vResult2 = False Then Exit Sub 'user cancelled
    > With Range
    > ("A3:AF3,B7:AC7,B11:AF11,B15:AE15,B19:AF19,B23:AE23,B27:AF2
    > 7,B31:AF31," & _
    > "B35:AE35,B39:AF39,B43:AE43,B47:AF47")
    >
    > .Replace _
    > What:=vResult1, _
    > Replacement:=vResult2, _
    > LookAt:=xlPart, _
    > SearchOrder:=xlByRows, _
    > MatchCase:=False
    >
    > End With
    > End Sub


    --

    Dave Peterson

+ Reply to Thread

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