Results 1 to 15 of 15

Macro to lookup a value in a Sheet and find that value in another sheet and Copy paste

Threaded View

  1. #10
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Re: Macro to lookup a value in a Sheet and find that value in another sheet and Copy paste

    Last week you have helped me by writing a code for me. The code works great. But I want to make a minor change. Some of the rows and columns in the the sheet CONSOLIDATED_RC I want to protect. (The sheet is protected). When I run the Macro gives me error:
    Run-time error '1004'
    Unable to set the autoFilterMode Property of the worksheet class.


    The protection does not allow the macro to remove the filter. Can you please modify the code to the perform the action on the protected Consolidated_RC sheet. The code is given as under:
    Sub copyRange()
        Application.ScreenUpdating = False
        Dim LastRow As Long
        LastRow = Sheets("Consolidated_RC").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        Dim foundVal As Range
        Set foundVal = Sheets("Consolidated_RC").Range("D:D").Find(Sheets("Data").Range("C3").Value, LookIn:=xlValues, lookat:=xlWhole)
        If Not foundVal Is Nothing Then
            Sheets("Consolidated_RC").Range("D1:D" & LastRow).AutoFilter Field:=1, Criteria1:=foundVal
            Sheets("Consolidated_RC").Range("B2:M" & LastRow).SpecialCells(xlCellTypeVisible).Copy
            Sheets("Data").Range("B9").PasteSpecial xlPasteValues
            Application.CutCopyMode = False
        End If
        If Sheets("Consolidated_RC").AutoFilterMode = True Then Sheets("Consolidated_RC").AutoFilterMode = False
        Application.ScreenUpdating = True
    End Sub
    Thanks in Advance.

    Khalid
    Last edited by Khalid.Noor; 04-11-2018 at 02:04 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA to find data in Sheet 2 copy and paste back in Sheet 1
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2014, 09:39 PM
  2. Macro to find numbers in column and copy/paste to other sheet
    By maxbeard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2013, 11:28 AM
  3. [SOLVED] Excel Macro to lookup sheet name with a range of cells and paste in the reference sheet
    By mishaq in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-08-2013, 02:55 PM
  4. [SOLVED] Need help with macro that will FIND, COPY & PAste to different sheet :)
    By MeloReese in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-13-2012, 08:03 AM
  5. VBA macro to Find a dynamic range of cells, copy then paste to another sheet
    By Bmxerdude2087 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2012, 02:36 PM
  6. Find Adjacent Data In One Sheet and Copy/Paste Into Other Sheet
    By jaylotheman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2011, 07:19 PM
  7. Find value from sheet 1, cell A1 in sheet(s) 2 (3, 4?), copy, paste row to sheet 8
    By fleeting in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2011, 03:31 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