Solved

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

Posted on 2012-04-03
1
158 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 41

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now