+ Reply to Thread
Results 1 to 4 of 4

Macro deleting everything from other page

  1. #1
    Registered User
    Join Date
    10-06-2017
    Location
    Leesburg, Virginia
    MS-Off Ver
    2016
    Posts
    4

    Macro deleting everything from other page

    Hello all,

    I wrote a macro to delete existing data on a summary worksheet and replace it with copied data from another worksheet within the same workbook, in order to refresh the summary sheet with updated data each time the workbook. It works well, but for some reason it deletes all items from another worksheet, even though it isn't referenced in the macro. Not only formulas, but any text as well - the only thing it doesn't clear out is formatting.


    Anyone know how to fix this? See code below.

    Thanks much!
    Leif






    Sub summary_transfer()


    Dim sh1 As Worksheet, sh2 As Worksheet
    Dim LstRw As Long
    Dim Rng As Range
    Dim C As Range

    With Worksheets("Summary")
    Rows("2:" & Rows.Count).ClearContents
    End With

    ' Keyetta

    ' exchange "Keyetta" in row below with new sheet name
    Set sh1 = Worksheets("Keyetta")
    Set sh2 = Worksheets("Summary")

    With sh1
    LstRw = .Cells(.Rows.Count, "K").End(xlUp).Row
    Set Rng = .Range("K1:K" & LstRw)
    For Each C In Rng.Cells
    If C = "NO" Then
    C.EntireRow.Copy sh2.Cells(sh2.Rows.Count, "A").End(xlUp).Offset(1)
    End If
    Next C
    End With


    ' End Keyetta

    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro deleting everything from other page

    Missing a period before Rows to reference the Summary worksheet

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-05-2017
    Location
    Tucson, Arizona
    MS-Off Ver
    2016
    Posts
    2

    Re: Macro deleting everything from other page

    missed that . too
    Last edited by ScoobyExcel; 10-12-2017 at 10:54 AM. Reason: answer posted while I was writing a post.

  4. #4
    Registered User
    Join Date
    10-06-2017
    Location
    Leesburg, Virginia
    MS-Off Ver
    2016
    Posts
    4

    Re: Macro deleting everything from other page

    Wonderful! Thanks so much, AlphaFrog and ScoobyExcel!

+ 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. deleting more than one page with macro's
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 11:05 AM
  2. [SOLVED] deleting more than one page with macro's
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 07:05 AM
  3. deleting more than one page with macro's
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  4. [SOLVED] deleting more than one page with macro's
    By Ron de Bruin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  5. [SOLVED] deleting more than one page with macro's
    By shrek in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  6. deleting more than one page with macro's
    By shrek in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. deleting more than one page with macro's
    By shrek in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. deleting more than one page with macro's
    By shrek in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-01-2005, 09:05 AM

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