Extracting Data from one sheet

inigotaojo

New Member
Joined
May 7, 2014
Messages
3
Hi guys, I need your help on this.

I have a table of data (in sheet "Masterlist"), and in one column I label it 0 or 1. I want a code to retrieve all rows labelled 0, and put it in a new sheet, and all rows labelled 1 and put it in another sheet.

Here's what I've coded so far:

Sub Extractdata()


Dim i As Integer
Dim j As Integer


For i = 2 To 10 'Countdata()
For j = 2 To 100 'Countdata()
If Worksheets("Masterlist").Range("F" & i) = "1" _
Then Range("F" & i).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("a" & j)

Next j
Next i




End Sub


'Sub Countdata()
'Dim lastrow As Long
'lastrow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
'End Sub

It retrieves "1" for now. It successfully retrieves some data, but not all and I'm wondering where I went wrong.

The countdata() part is still under progress, and if you could also help me with that I'd be grateful. It's a sub to count how many rows are filled in on the masterlist sheet to put as a max value for my i.


Many thanks in advance from a vba beginner! :)
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Looks like I got it to work. (Except for the countdata part). It's weird though, cause combining everything using the call procedure sometimes produces errors. Anyone have any clue why this happens?
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,391
Members
449,445
Latest member
JJFabEngineering

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