VBA code converting cell to Table

Evapar18

Board Regular
Joined
Aug 3, 2018
Messages
86
Office Version
  1. 2019
Platform
  1. Windows
dYE9lDjIKcMF
I used this same code in another worksheet but with different ranges without issue. Now when I run the same code it causes the first cell under QTY to become a table. Any idea what would cause this?

I did find if I rem out " srcWS.Range("AD4:AD52").AutoFilter Field:=1, Criteria1:="<>" " the entire row becomes a table...??

https://www.screencast.com/t/dYE9lDjIKcMF
dYE9lDjIKcMF


Code:
Private Sub CommandButton1_Click()'Unprotect a worksheet with a password
'Sheets("Pre-Quote").Unprotect Password:=""


'Sheets("Engine Options").EnableSelection = xlNoRestrictions


    Application.ScreenUpdating = False
    
    Dim srcWS As Worksheet, desWS As Worksheet
    
    Set srcWS = ThisWorkbook.Sheets("Engine Options")
     
    'Qty Filter
    srcWS.Range("AD4:AD52").AutoFilter Field:=1, Criteria1:="<>"
    
    'Criteria Filter
    srcWS.Range("Y4:AD52").AutoFilter Field:=1, Criteria1:="<>-"
    srcWS.Range("Y4:AD52").AutoFilter Field:=1, Criteria1:="<>-"
        
    'Quote WorkBook Path
    Set desWS = ThisWorkbook.Sheets("Pre-Quote")
    
    'Qty to Quote Workbook
    srcWS.Range("AD4:AD52").SpecialCells(xlCellTypeVisible).Copy
    desWS.Range("B10").PasteSpecial xlPasteValues
    
    'Part Number
    srcWS.Range("Z4:Z52").SpecialCells(xlCellTypeVisible).Copy
    desWS.Range("D10").PasteSpecial xlPasteValues
    
    'Description
    srcWS.Range("AA4:AA52").SpecialCells(xlCellTypeVisible).Copy
    desWS.Range("F10").PasteSpecial xlPasteValues
        
    'Cost
    srcWS.Range("AC4:AC52").SpecialCells(xlCellTypeVisible).Copy
    desWS.Range("T10").PasteSpecial xlPasteValues
    
    'srcWS.Range("AL7").AutoFilter
        
    Application.ScreenUpdating = True
    
   Call Copy_Paste
      
    'Worksheets("Engine Options").Activate
    
'Protect worksheet with a password
'ActiveSheet.Protect Password:=""


    'Sheet2.Protect Password:="", AllowFormattingCells:=True, AllowFormattingColumns:=False, _
    'AllowFormattingRows:=True, AllowSorting:=False, AllowFiltering:=False, UserInterfaceOnly:=True
        
    'Worksheets("Pre-Quote").Activate
        
    'Sheet4.Protect Password:="", AllowFormattingCells:=True, AllowFormattingColumns:=False, _
    'AllowFormattingRows:=True, AllowSorting:=False, AllowFiltering:=False, UserInterfaceOnly:=True
    


End Sub

Lost and confused?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top