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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,129,751
Messages
5,638,145
Members
417,010
Latest member
jnuss03

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
Top