Copy Selected Names To A Different Sheet

cmangi

New Member
Joined
Jul 17, 2014
Messages
17
Looking for some help creating an macro to automate a task.

The excel file I am working with contains two (2) tabs: 1) Upload Sheet and 2) Database Sheet. The Database Sheet contains a large list of names (reference column B in example below). We use Column A to select the desired name (reference "X"s in example below) to be transferred to the Upload Sheet.

Looking for a macro that will copy all names in Column B identified with a non-blank cell in Column A of the Database Sheet to Column A of the Upload Sheet. See example below

Ideally there are no blank rows in the Upload Sheet after copying.

DATA BASE SHEET
COLUMN ACOLUMN B
Row 3XJohn
Row 4Frank
Row 5XBill

UPLOAD SHEET AFTER MACRO Result
COLUMN A
Row 2John
Row 3Bill
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
With Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each ([Column1] = "X")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Column1"})
in
    #"Removed Columns"
 
Upvote 0
Try this

VBA Code:
Sub Macro1()
  Dim lr As Long
  With Sheets("Database")
    If .AutoFilterMode Then .AutoFilterMode = False
    lr = .Range("B" & Rows.Count).End(3).Row
    .Range("A2:B" & lr).AutoFilter Field:=1, Criteria1:="<>"
    .Range("B3:B" & lr).Copy Sheets("Upload").Range("A2")
    .ShowAllData
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,877
Messages
6,175,139
Members
452,615
Latest member
bogeys2birdies

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