Copy information based on criteria using VBA

alex_a

Board Regular
Joined
Feb 27, 2012
Messages
51
Greetings,

I have the follwoing code developed:
For i = 35 To rcnt
If LCase(Range("D" & i).Value) = "no" Or LCase(Range("D" & i).Value) = "no-rq" Then
Range("A" & i).Copy (Sheets("1").Range("B" & j))
Range("C" & i).Copy (Sheets("1").Range("C" & j))
Range("F" & i).Copy (Sheets("1").Range("D" & j))
j = j + 1
End If
Next
End Sub
This code transfer infromation from one sheet to a sheet called "sheet 1" based on "no" answers. I am trying to transfer infromation to another sheet, called "sheet 2" if there is a "yes" answer. Your help is greatly appreciated.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You will need to edit the sheet and ranges, but this is the general idea.
Code:
For i = 35 To rcnt
If LCase(Range("D" & i).Value) = "no" Or LCase(Range("D" & i).Value) = "no-rq" Then
Range("A" & i).Copy (Sheets("1").Range("B" & j))
Range("C" & i).Copy (Sheets("1").Range("C" & j))
Range("F" & i).Copy (Sheets("1").Range("D" & j))
j = j + 1
ElseIf LCase(Range("D" & i).Value) = "yes"
Range("A" & i).Copy (Sheets("2").Range("B" & j))
Range("C" & i).Copy (Sheets("2").Range("C" & j))
Range("F" & i).Copy (Sheets("2").Range("D" & j))
End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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