Copy and Paste adjacent cells

sjfir

New Member
Joined
Aug 24, 2009
Messages
47
Hi, I have a workbook that has 2 sheets on sheet 1 there are 3columns as below:<o:p></o:p>
A<o:p></o:p>
B<o:p></o:p>
C<o:p></o:p>
0<o:p></o:p>
0<o:p></o:p>
0<o:p></o:p>
1<o:p></o:p>
1.5<o:p></o:p>
AA<o:p></o:p>
1<o:p></o:p>
1.7<o:p></o:p>
<o:p></o:p>
BB<o:p></o:p>
1<o:p></o:p>
1.6<o:p></o:p>
EE<o:p></o:p>
1<o:p></o:p>
0.4<o:p></o:p>
DD<o:p></o:p>
0<o:p></o:p>
0<o:p></o:p>
0<o:p></o:p>

<TBODY>
</TBODY>
On Sheet 2 there are two columns that I want to copy all the cells in Columns B&C from Sheet ! that have a 1 in column A. <o:p></o:p>
I have tried Vlookup and Index/Match without success. The idea is that once the data is copied I can then sort into order by column B.<o:p></o:p>
<o:p></o:p>
Sheet 2 would look like this before sorting.<o:p></o:p>
A<o:p></o:p>
B<o:p></o:p>
1.5<o:p></o:p>
AA<o:p></o:p>
1.7<o:p></o:p>
BB<o:p></o:p>
1.6<o:p></o:p>
EE<o:p></o:p>
0.4<o:p></o:p>
DD<o:p></o:p>

<TBODY>
</TBODY>
<o:p></o:p>
Just to add there approx. 850 rows in sheet 1 of which only about 25-50 will have the 1, this will change daily depending on calculations from another workbook. Any help greatly appreciated.<o:p></o:p>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This macro may do what you want:
Code:
Sub CopyRange()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("Sheet2").UsedRange.ClearContents
    ActiveSheet.Range("$A$1:$C$" & LastRow).AutoFilter Field:=1, Criteria1:="1"
    ActiveSheet.Range("B2:C" & LastRow).SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").Cells(1, 1)
    If Sheets("Sheet1").FilterMode Then Sheets("Sheet1").ShowAllData
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks, it worked the only issue is that in those cells are formulae and I need to copy the value and not the formulae, the copied cells all say ref!
 
Upvote 0
Maybe:
Code:
Sub CopyRange()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("Sheet2").UsedRange.ClearContents
    ActiveSheet.Range("$A$1:$C$" & LastRow).AutoFilter Field:=1, Criteria1:="1"
    ActiveSheet.Range("B2:C" & LastRow).SpecialCells(xlCellTypeVisible).Copy
    Sheets("Sheet2").Cells(1, 1).PasteSpecial xlPasteValues
    If Sheets("Sheet1").FilterMode Then Sheets("Sheet1").ShowAllData
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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