Dear all,
I want to populate some columns base don some condition in 2 different columns in another worksheet. this is what I am doing:
Set spRange = Worksheet1.Range("D3", "H" & GetLastRowWithData)
//where D and H column contains values such as "forward" and "roll" respecitvely along with lots of other values
For Each cell In spRange
If cell.Value = "Forward" Then
copyRowTo sharePoint.Range("C" & cell.Row), Worksheet2, 1 //copying row to next sheet successfully
End If
Next cell //this function is successfully copying rows which are having value as forward in column D.
.
but What I want is to copy rows ONLY if the value in column D and H is "Forward" and "roll" respectively or may be something like:
For Each cell In spRange
If cell.Value = "Forward" And cell.value ="Roll" Then
copyRowTo sharePoint.Range("C" & cell.Row), ChartSpotDollar, 1 //copying row to next sheet successfully
End If
Next cell
How can I do this?
Any help would be much appreiacted..!!
Hi, welcome to the forum.Please take a moment to read the forum rules. suppose very first row has column headings and try this code:
Sub shau() Dim rngLast As Range, i As Long, j As Long,k as long Set rngLast = Sheets("sheet1").Range("D1").SpecialCells(xlCellTypeLastCell) j = rngLast.Row For i = 1 To j With Sheets("sheet1") If Cells(i, 4).Value = "forward" And Cells(i, 8).Value = "roll" Then .Rows(i).Copy Else GoTo error End If End With With Sheets("sheet2") k = .UsedRange.Rows.Count .Rows(k + 1).PasteSpecial End With error: Next End Sub
Last edited by shaukat; 12-15-2011 at 04:52 PM. Reason: explaination
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks