Solved

Added column to this sheet now my macro isn't working

Posted on 2012-04-03
1
167 Views
Last Modified: 2012-04-03
I added the column labled PAYPAL to the sheet called "DATABASE, now when I run my daily macro in the sheet called "DAILY SUMMARY" I am getting a debug message.  This sheet should pick up all activity from the databse sheet for the day entered in the upper left.
experts2.xls
0
Comment
Question by:wcody
1 Comment
 
LVL 42

Accepted Solution

by:
dlmille earned 500 total points
ID: 37801767
It appears your compare date moved from column J to Column K.  See line 11 corrected.  Also, you can use .Rows.Count property rather than 65535 and then when you upgrade to newer Excel versions the number would change for max rows.  with this version, .Rows.Count would equal 65535.

See updated code:

Sub Button1_Click()
    Application.ScreenUpdating = False
 
    Dim rng As Range, cell As Range, x As String
    Dim ws As Worksheet, ws1 As Worksheet
    Set ws = Sheets("Daily Summary")
    Set ws1 = Sheets("Database")
    x = ws.Range("B1")
    If ws.Cells(4, 1).Value <> "" Then ws.Range("A4:G" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row).ClearContents
    If x <> "" Then
        Set rng = ws1.Range("k6:k" & ws1.Cells(ws.Rows.Count, "k").End(xlUp).Row)
        For Each cell In rng
            If DateValue(cell.Value) = DateValue(x) Then
                ws1.Range("A" & cell.Row & ":H" & cell.Row).Copy ws.Range("A" & ws.Cells(ws.Rows.Count, "a").End(xlUp).Row + 1)
            End If
        Next cell
    End If
    Cells.Select
    Selection.EntireColumn.AutoFit
    Range("a1").Select
    MsgBox "Done"
 
 
    Application.ScreenUpdating = True
 
End Sub

Open in new window


See attached.

Cheers,

Dave
experts2.xls
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question