• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Code not firing on every activation

SolemnSpirit

New Member
Hi, I have the following code to filter a table, select the visible cells from one of its columns and then paste the contents to another sheet.

Code:
Worksheets("QEImportData").ListObjects("QE_Import_Data").Range.AutoFilter Field:=41, Criteria1:="Closed"
Worksheets("QEImportData").ListObjects("QE_Import_Data").ListColumns(41).DataBodyRange.Copy Worksheets("Metrics").Range("U3")

The code is currently in a button click event but for some reason will only work the second time the button is pressed or the first time if I enter a cell and press enter or calculate the sheet first.

Any ideas why this would be ?
 
Hi ,

What happens when you click the button only once ?

Does the range filter ?

Is the AutoFilter line of code preceded by a line which clears all filters ? If yes , then what happens when you click the button only once ?

Narayan
 
Clicking the button once filters as expected. The code above is the only code in the event at present.

*Edit* Have added the following above the previous code
Code:
Worksheets("QEImportData").ListObjects("QE_Import_Data").AutoFilter.ShowAllData
and the event now seems to fire every time.
 
Back
Top