Link to home
Start Free TrialLog in
Avatar of Mac M
Mac MFlag for United States of America

asked on

Access VBA Question

I have a Clear Form Button when clicked on my Excel Spreadsheet that is not clearing 2 records for some strange reason, can anyone possibly tell me why this is happening...Please review my code below....

Sub ClearForm()
'
' ClearForm Macro
'

'
    Range("Table_Query_from_MS_Access_Database").Select
    Selection.AutoFilter
    Selection.AutoFilter
    Range("Table_Query_from_MS_Access_Database_1").Select
    Selection.AutoFilter
    Selection.AutoFilter
    Range("B3").Select
    Selection.ClearContents
    Range("B5").Select
    Selection.ClearContents
    Range("B7").Select
    Selection.ClearContents
    Range("Table_Query_from_MS_Access_Database[[#Headers],[GroupCode]]").Select
    Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub
Avatar of ste5an
ste5an
Flag of Germany image

The question is simple: What is a record and why should it be cleared?

Sub ClearForm()
  
  Range("Table_Query_from_MS_Access_Database").AutoFilter     
  Range("Table_Query_from_MS_Access_Database_1").AutoFilter     
  Range("B3").ClearContents
  Range("B5").ClearContents
  Range("B7").ClearContents
  Range("Table_Query_from_MS_Access_Database[[#Headers],[GroupCode]]").ListObject.QueryTable.Refresh BackgroundQuery:=False

End Sub 

Open in new window

Your macro is clearing just three cells. Nothing else..
ASKER CERTIFIED SOLUTION
Avatar of Mac M
Mac M
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial