VBA - slight issue with copying info

storemannequin

Board Regular
Joined
May 29, 2010
Messages
108
EDIT: Nevermind, I forgot to reference the original worksheet here. Mods can delete


Not sure exactly why this code is giving me problems, I see that it correctly locates the value of i, but doesn't copy over at all. The title header copies over but not the info in the loop:

Code:
Sub FedLoop()
FR = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
FC = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Set WBO = ActiveWorkbook
Set WSO = ActiveSheet
Set WBD = Workbooks.Add(template:=xlWBATWorksheet)
Set WSD = WBD.Worksheets(1)
WSO.Range("A1").CurrentRegion.Rows(1).Copy Destination:=WSD.Range("A1")
nextrow = 2
For i = 2 To FR
 
    If Cells(i, 2).Value = "peace" Then
        WSO.Cells(i, 1).Resize(, FC).Copy Destination:=WSD.Cells(nextrow, 1)
        nextrow = nextrow + 1
    End If
 
 
Next i
End Sub
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

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