+ Reply to Thread
Results 1 to 4 of 4

Macro / VBA Script to delete ROW(s) on locked worksheet

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2016
    Posts
    140

    Macro / VBA Script to delete ROW(s) on locked worksheet

    Hello,

    ** Additional Info: I am using Excel 2013, no later versions are available **
    ** Spreadsheet attached **

    I have a worksheet that contains URLs that have been blocked. When a URL is entered, it highlights if it has already been entered. For ease, I have tried to create a macro that un-protects the sheet and deletes the current ROW.
    This macro works fine if I go into Macros, highlight it and select "Run" however if I assign the macro to a button on the ribbon and click on it, it tries to re-open the spreadsheet and I cannot work out why.

    To get the macro, I simply recorded the actions and saved it....
    Please Login or Register  to view this content.
    Please could someone take a look and explain where I am going wrong. Thank you
    Attached Files Attached Files
    Last edited by mowens74; 10-19-2017 at 05:49 AM. Reason: Additional information and attachment added

  2. #2
    Registered User
    Join Date
    10-19-2017
    Location
    Timashevsk, Russia
    MS-Off Ver
    Professional Plus 2010
    Posts
    8

    Re: Macro / VBA Script to delete ROW(s) on locked worksheet

    Hi,
    Attach the file please so we can look closer.
    My first guess. The reason may be that "ActiveSheet" object isn't assigned correctly when working from a ribbon. Try Application.ActiveWorkbook.Sheets(1) or Application.ActiveWorkbook.Sheets("Sheet_Name_Here") instead of ActiveSheet.

  3. #3
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2016
    Posts
    140

    Re: Macro / VBA Script to delete ROW(s) on locked worksheet

    Hi,

    I have tried your suggestion and it doesn't work, it doesn't like the '.Sheets' section of either of the lines mentioned above. I did forget to mention that I am using Excel 2013, there is no later version available. I have added a copy of the speadsheet with a 'test' line.

  4. #4
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2016
    Posts
    140

    Re: Macro / VBA Script to delete ROW(s) on locked worksheet

    ** UPDATE - RESOLVED **

    OK, so I have resolved the issue but not entirly sure how I did it.

    Code I used;
    Please Login or Register  to view this content.
    I started a new spreadsheet and re-created the macro which worked. It worked by running the macro and from a keyboard shortcut but was still failing when I assigned it to a ribbon button. Then I changed the option "Customize Quick Access Toolbar" so that it was for the specific spreadsheet and not for all documents. The button is now working.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. script to run the macro from Vb script with out opening the excel file
    By chandanp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2021, 03:33 AM
  2. [SOLVED] Can't delete rows when row contains locked cells using VBA code.
    By PitBoo in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-31-2017, 03:37 PM
  3. [SOLVED] Help with macro or script to delete specific columns from worksheet
    By damjerm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-23-2013, 01:40 PM
  4. Replies: 2
    Last Post: 03-07-2012, 09:42 AM
  5. [SOLVED] Script to delete certain columns in a worksheet
    By dip11 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2012, 11:02 AM
  6. Macro or script to delete rows that meet certain criteria
    By stlawr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2011, 11:36 AM
  7. Locked worksheet based upon date and locked columns when worksheet is not locked
    By ruralbrew in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-09-2011, 05:18 PM

Tags for this Thread

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