Transfer a Range of data if a requirement is met

PMJonas

New Member
Joined
Jan 24, 2014
Messages
5
Hey
I’m about to make a macro that transfer a Range of data from Sheet1 to Sheet2 in the excel. The transfer should take place for each row if a requirement is met.


More specific if the data on Sheet1 is for example:

Staff hours

Consulting hours

Driving

Test

Staff hours

In the macro it only supposed to send the data associated with Staff hours.
I have a macro that works but only if it is with one cell and not with the whole Range:

Sub Identificer()

Dim text As String
text = Range("A1").Value

If text = "Staff hours" Then result = Worksheets("Sheet2").Range("I1")

Range("B1").Value = result

End Sub

It don’t work if you write:
Sub Identificer()

Dim text As String
text = Range("A1:A2").Value

If text = "Personaletimer" Then result = Worksheets("Ark2").Range("I1:I2")

Range("B1:B2").Value = result

End Sub

I think maybe there should be another data before sub.

Can somebody help me?


 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,215,221
Messages
6,123,699
Members
449,117
Latest member
Aaagu

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