Copy filtered table data to another sheet in same workbook

robertmwaring2

Board Regular
Joined
Mar 8, 2019
Messages
132
Office Version
  1. 365
Platform
  1. Windows
I am unable to find a solution that works for this in previous threads - hoping I will get lucky and someone can assist me.

This is my workbook

It has a few forms in that that the user either enters or selects data. One form uses data from another form but ultimately all the data ends up in the same worksheet. I have this bit of code (below) that I was excited worked until I attached it to a button on one of the forms.

VBA Code:
Dim LR As Long
LR = Sheet5.Cells(Rows.Count, 1).End(xlUp).Row + 1

Sheet5.Range("A" & LR).Value = LBDISPLAY.Caption
Sheet3.Range("Table1[INGREDIENT]").Select
    Selection.Copy
    Sheet5.Range("A" & LR).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
Sheet3.Range("Table1[TOTAL]").SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheet5.Range("B" & LR).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
Sheet3.Range("Table1[UOM]").SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheet5.Range("C" & LR).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
Sheet3.Range("Table1[NOTES]").SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheet5.Range("D" & LR).PasteSpecial Paste:=xlPasteValues

Basically what is happening is based upon user inputs, the data in Table1 on Sheet3 is filtered, some additional info is added, etc. When I click the button (badd) on the userform (UFADD), I am trying to apply one last filter to the data, and copy 4 of the columns ([Ingredient], [Total], [UOM], [Notes]) to sheet5 in the same workbook. When I initially was working through this to get it together, I simply "Sheet3.Range("Table1[INGREDIENT]").Select", which seemed to work fine in a module but does not when attached to the button. I found some resources that suggest using the following iteration "Sheet3.Range("Table1[Ingredient]").SpecialCells(xlCellTypeVisible).Select" but it does not appear to work either. Can anyone assist?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try getting rid of the selects like
VBA Code:
Dim LR As Long
LR = Sheet5.Cells(Rows.Count, 1).End(xlUp).Row + 1

Sheet5.Range("A" & LR).Value = LBDISPLAY.Caption
Sheet3.Range("Table1[INGREDIENT]").Copy
    Sheet5.Range("A" & LR).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
Sheet3.Range("Table1[TOTAL]").SpecialCells(xlCellTypeVisible).Copy
    Sheet5.Range("B" & LR).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
Sheet3.Range("Table1[UOM]").SpecialCells(xlCellTypeVisible).Copy
    Sheet5.Range("C" & LR).PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
Sheet3.Range("Table1[NOTES]").SpecialCells(xlCellTypeVisible).Copy
    Sheet5.Range("D" & LR).PasteSpecial Paste:=xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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