Results 1 to 19 of 19

Amend VBA Code to Clear Data

Threaded View

  1. #1
    Registered User
    Join Date
    08-28-2013
    Location
    Laem Chabang, Thailand
    MS-Off Ver
    Excel 2010
    Posts
    47

    Amend VBA Code to Clear Data

    The code below takes download information for a month and copies it to another sheet in the next open column. The problem is that if new download information is used for the same month, it will go into the next open column (say October) rather than the one previously populated (September). The code below is for the first time use of the download information. What code addition will bring up a message box that says:

    "Is this your first download of this month's info?" with a Yes or No feature.

    If the answer is Yes, the code places the download info in the next open column (September). If the answer is No, the code clears the last populated column (September) then functions as written placing the download information in the open column (September).

    Sub Column_Fill()   ' Used for first time copying of download to info tab
    
    Dim rng As Range    ' Range of argument answers
    Dim rng2 As Range   ' Each instance of an argument answer
    Dim rng3 As Range   ' Source information
    Dim i As Integer
    
    Set rng3 = Worksheets("Download").Range("d2:d1100")
    Set rng = Worksheets("Info").Range("e3:p1100")
    
                                                           
    For Each rng2 In rng
        If rng2 = "" Then
            rng3.Copy                           ' range (source) to copy
            rng2.PasteSpecial (xlPasteValues)   ' where to copy as a value rather than formula
            Application.CutCopyMode = False
            Exit Sub
        Else
                'Do Nothing
        End If
    Next rng2
            
    End Sub
    I appreciate any help that is given.
    Last edited by Leith Ross; 09-26-2014 at 03:00 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VB Code to Clear the data
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2012, 03:37 PM
  2. Amend code to run faster
    By SOS in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-05-2008, 10:09 AM
  3. Amend Code help
    By VBA Noob in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-21-2006, 03:16 PM
  4. Amend code
    By VBA Noob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2006, 05:32 PM
  5. Amend the Code
    By shan_in_dubai in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2005, 04:36 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