Copy specific data into two columns from a worksheet with a lot of data

marresni

New Member
Joined
Apr 22, 2015
Messages
3
Okay here we go.

What I have is a excel workbook with a lot of data from columns A to AZ filled with data. What i am trying to do is create a vba code that will take data from two of these columns, and display them on another worksheet.

For example this is what the excel sheet looks like with less columns

[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]14545523[/TD]
[TD]adsf[/TD]
[TD]achr[/TD]
[TD]dsaf[/TD]
[/TR]
[TR]
[TD]13252352[/TD]
[TD]sadf[/TD]
[TD]cond[/TD]
[TD]asdf[/TD]
[/TR]
[TR]
[TD]25231552[/TD]
[TD]asdf[/TD]
[TD]rlse[/TD]
[TD]adsf[/TD]
[/TR]
[TR]
[TD]12532352[/TD]
[TD]adsf[/TD]
[TD]rlse[/TD]
[TD]asdf[/TD]
[/TR]
[TR]
[TD]25236364[/TD]
[TD]asff[/TD]
[TD]btfr[/TD]
[TD]asfd[/TD]
[/TR]
</tbody>[/TABLE]

What i would like is a code that could look in column c and identify everything that is not cond or rlse, and throw that into a new column on a different sheet. I would also like whatever corresponding cell in column A data to be transferred into a column on a new work sheet.

This is then the result i would like to see with this data specifically:

[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]14545523[/TD]
[TD]achr[/TD]
[/TR]
[TR]
[TD]25236364[/TD]
[TD]btfr[/TD]
[/TR]
</tbody>[/TABLE]


Please help!!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
Sub cpystuff()
Dim sh1 As Worksheet, sh2 As Worksheet, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
sh1.Range("A1", sh1.Cells(Rows.Count, 3).End(xlUp)).AutoFilter 3, "<>" & "cond", xlAnd, "<>" & "rlse"
Set rng = Union(sh1.Columns(1), sh1.Columns(3))
rng.SpecialCells(xlCellTypeVisible).Copy sh2.Range("A1")
sh1.AutoFilterMode = False
End Sub
 
Upvote 0
Code:
Sub cpystuff()
Dim sh1 As Worksheet, sh2 As Worksheet, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
sh1.Range("A1", sh1.Cells(Rows.Count, 3).End(xlUp)).AutoFilter 3, "<>" & "cond", xlAnd, "<>" & "rlse"
Set rng = Union(sh1.Columns(1), sh1.Columns(3))
rng.SpecialCells(xlCellTypeVisible).Copy sh2.Range("A1")
sh1.AutoFilterMode = False
End Sub

This worked for the two rlse and cond, but what if i needed to add more filters such as XMPT or EXAM
 
Upvote 0
this might work
Code:
Sub cpystuff()
Dim sh1 As Worksheet, sh2 As Worksheet, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
sh1.Range("A1", sh1.Cells(Rows.Count, 3).End(xlUp)).AutoFilter 3, Array("cond", "rise", "XMPT", "EXAM"), xlFilterValues
Set rng = Union(sh1.Columns(1), sh1.Columns(3))
rng.SpecialCells(xlCellTypeVisible).Copy sh2.Range("A1")
sh1.AutoFilterMode = False
End Sub
 
Upvote 0
JLG this did not work it did the opposite of what i needed it to do, which also works I will just need to adjust it slightly by adding all the statuses. Thanks for your help.

this might work
Code:
Sub cpystuff()
Dim sh1 As Worksheet, sh2 As Worksheet, rng As Range
Set sh1 = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit sheet name
sh1.Range("A1", sh1.Cells(Rows.Count, 3).End(xlUp)).AutoFilter 3, Array("cond", "rise", "XMPT", "EXAM"), xlFilterValues
Set rng = Union(sh1.Columns(1), sh1.Columns(3))
rng.SpecialCells(xlCellTypeVisible).Copy sh2.Range("A1")
sh1.AutoFilterMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,226,693
Messages
6,192,464
Members
453,725
Latest member
cvsdatreas

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