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!
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!