Results 1 to 16 of 16

VBA code for 2 buttons that can clear cells in a row then second button to bring data back

Threaded View

  1. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,447

    Re: VBA code for 2 buttons that can clear cells in a row then second button to bring data

    .
    I believe this is what you were seeking :

    Option Explicit
    
    Sub cpyPaste()
        
    Dim ws As Worksheet
    Dim cell As Variant
    Dim LastRow As Long
    
    Set ws = Sheets("Sheet2")
       
    LastRow = ws.Cells(Rows.Count, 5).End(xlUp).Row
        
        Application.ScreenUpdating = False
        
        Sheets("Sheet1").Range("D5:L5").Copy
        ws.Activate
        ws.Cells(LastRow + 1, 4).Select
        ws.Paste
        Sheet1.Rows(5).Delete
        Sheets("Sheet1").Activate
        
        Application.CutCopyMode = False
        Application.ScreenUpdating = True
        
    End Sub
    
    Sub renew()
    Dim ws As Worksheet
    Dim cell As Variant
    Dim LastRow As Long
    
    Set ws = Sheets("Sheet2")
       
    LastRow = ws.Cells(Rows.Count, 5).End(xlUp).Row
    
    Application.ScreenUpdating = False
    
    If ws.Cells(LastRow, 5).Value = "" Then
        MsgBox "All data retrieved.", vbInformation, "Data Retrieval"
        Exit Sub
    End If
    
        Application.ScreenUpdating = False
        ws.Cells(LastRow, 5).EntireRow.Copy
        Sheets("Sheet1").Rows(5).Insert
        ws.Cells(LastRow, 5).EntireRow.Delete
        Application.CutCopyMode = False
        
        ws.Activate
        ws.Range("A1").Select
        Sheet1.Activate
        
    Application.ScreenUpdating = True
    
    End Sub
    
    Sub usdRng()
    Dim LastRow As Long
    Dim ws As Worksheet
    
    Set ws = Sheets("Sheet2")
    
    LastRow = ws.Cells(Rows.Count, 5).End(xlUp).Row
    
    Application.ScreenUpdating = False
    
    If ws.Cells(LastRow, 5).Value = "" Then
        MsgBox "All data retrieved.", vbInformation, "Data Retrieval"
        Exit Sub
    End If
    
        Worksheets("Sheet2").Activate
        ActiveSheet.UsedRange.Copy
    
        Sheets("Sheet1").Select
        Sheets("Sheet1").Range("D5").Insert shift:=xlShiftDown
        
        Worksheets("Sheet2").Cells.Delete
        Application.CutCopyMode = False
        
        ws.Activate
        ws.Range("A1").Select
        Sheet1.Activate
        
    Application.ScreenUpdating = True
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 12-12-2017, 12:49 PM
  2. [SOLVED] Help with code to creat Reset button to clear cells and copy back the original formula
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2015, 02:25 PM
  3. Array Formula Lookup - Bring back Lowest Date + Bring Back Cell Location
    By Matt1998 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-04-2014, 12:08 PM
  4. Replies: 3
    Last Post: 06-05-2012, 04:36 AM
  5. Replies: 2
    Last Post: 02-09-2009, 05:07 AM
  6. Create a button to clear data in certain cells
    By headbanger51 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-07-2008, 03:18 AM

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