copy consecutive numbers in filter data

ANTONIO1981

Board Regular
Joined
Apr 21, 2014
Messages
162
HI all

I have a list of codes in Column A in a workbook

A1 to A100

i want to paste them into a filter list in another workbook that countains 100 items too but as mentioned within filter.

I tried paste visible things only but doesn't work

any solution?

thanks in advance

Antonio
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
See if this information useful to you: https://www.youtube.com/watch?v=FUXQwP3jaUo
If it doesn't work, you can try my code below.
I created a code to copy paste to a filtered range.

Code:
[FONT=lucida console][COLOR=Royalblue]Sub[/COLOR] CopyVisibleToVisible1()
[I][COLOR=seagreen]'use this for:[/COLOR][/I]
[I][COLOR=seagreen]'Copy paste(value only):[/COLOR][/I]
[I][COLOR=seagreen]'from filtered range to filtered range[/COLOR][/I]
[I][COLOR=seagreen]'from filtered range to unfiltered range[/COLOR][/I]
[I][COLOR=seagreen]'from unfiltered range to filtered range[/COLOR][/I]
[I][COLOR=seagreen]'Not work on hidden column[/COLOR][/I]

    [COLOR=Royalblue]Dim[/COLOR] rngA [COLOR=Royalblue]As[/COLOR] Range
    [COLOR=Royalblue]Dim[/COLOR] rngB [COLOR=Royalblue]As[/COLOR] Range
    [COLOR=Royalblue]Dim[/COLOR] r [COLOR=Royalblue]As[/COLOR] Range
    [COLOR=Royalblue]Dim[/COLOR] Title [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]String[/COLOR]
    [COLOR=Royalblue]Dim[/COLOR] ra [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
    [COLOR=Royalblue]Dim[/COLOR] rc [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
    
    [COLOR=Royalblue]On[/COLOR] [COLOR=Royalblue]Error[/COLOR] [COLOR=Royalblue]GoTo[/COLOR] [COLOR=Royalblue]skip[/COLOR]:
    
    Title = [COLOR=brown]"Copy Visible To Visible"[/COLOR]
    [COLOR=Royalblue]Set[/COLOR] rngA = Application.Selection
    [COLOR=Royalblue]Set[/COLOR] rngA = Application.InputBox([COLOR=brown]"Select Range to Copy then click OK:"[/COLOR], Title, rngA.Address, [COLOR=Royalblue]Type[/COLOR]:=[COLOR=crimson]8[/COLOR])
    
    [COLOR=Royalblue]Set[/COLOR] rngB = Application.InputBox([COLOR=brown]"Select Range to Paste (select the first cell only):"[/COLOR], Title, [COLOR=Royalblue]Type[/COLOR]:=[COLOR=crimson]8[/COLOR])
    [COLOR=Royalblue]Set[/COLOR] rngB = rngB.Cells([COLOR=crimson]1[/COLOR], [COLOR=crimson]1[/COLOR])
    Application.ScreenUpdating = [COLOR=Royalblue]False[/COLOR]

    ra = rngA.Rows.count
    [COLOR=Royalblue]If[/COLOR] ra = [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]Then[/COLOR] rngB.Value = rngA.Value: [COLOR=Royalblue]Exit[/COLOR] [COLOR=Royalblue]Sub[/COLOR]
    rc = rngA.Columns.count
    [COLOR=Royalblue]Set[/COLOR] rngA = rngA.Cells([COLOR=crimson]1[/COLOR], [COLOR=crimson]1[/COLOR]).Resize(ra, [COLOR=crimson]1[/COLOR])
    
    [COLOR=Royalblue]For[/COLOR] [COLOR=Royalblue]Each[/COLOR] r [COLOR=Royalblue]In[/COLOR] rngA.SpecialCells(xlCellTypeVisible)
      rngB.Resize([COLOR=crimson]1[/COLOR], rc).Value = r.Resize([COLOR=crimson]1[/COLOR], rc).Value
        [COLOR=Royalblue]Do[/COLOR]
          [COLOR=Royalblue]Set[/COLOR] rngB = rngB.Offset([COLOR=crimson]1[/COLOR], [COLOR=crimson]0[/COLOR])
        [COLOR=Royalblue]Loop[/COLOR] [COLOR=Royalblue]Until[/COLOR] rngB.EntireRow.Hidden = [COLOR=Royalblue]False[/COLOR]
    [COLOR=Royalblue]Next[/COLOR]
    
    Application.Goto rngB
    Application.ScreenUpdating = [COLOR=Royalblue]True[/COLOR]
    Application.CutCopyMode = [COLOR=Royalblue]False[/COLOR]
[COLOR=Royalblue]Exit[/COLOR] [COLOR=Royalblue]Sub[/COLOR]
[COLOR=Royalblue]skip[/COLOR]:
    [COLOR=Royalblue]If[/COLOR] err.Number <> [COLOR=crimson]424[/COLOR] [COLOR=Royalblue]Then[/COLOR]
        MsgBox [COLOR=brown]"Error found: "[/COLOR] & err.Description
    [COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
    
    Application.ScreenUpdating = [COLOR=Royalblue]True[/COLOR]
    Application.CutCopyMode = [COLOR=Royalblue]False[/COLOR]

[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]
 
Upvote 0
I have a list of codes in Column A in a workbook

A1 to A100

i want to paste them into a filter list in another workbook that countains 100 items too but as mentioned within filter.
I'll let you adjust the code for your different workbooks, but here is how you could do it for different sheets within the same workbook. My assumption is that your list is in cells A1:A100 on Sheet 1 and is NOT filtered... the cells on Sheet2 are filtered and you want to put the values from cells A1:A100 on Sheet1 into the visible cells of Sheet2 starting at cell C2 (cell C1 is assumed to be a header cell).
Code:
Sub CopyListToVisibleCells()
  Dim N As Long, R As Variant
  For Each R In Sheets("Sheet2").Range("C2:C" & rows.count).SpecialCells(xlVisible)
    N = N + 1
    R.Value = Sheets("Sheet1").Cells(N, "A").Value
    If N = 100 Then Exit For
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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