Hi guys,
Im just wondering if anyone has a solution for this. In the code below I have a part with "for I = 20 to 108" which obviously uses the values from row 20 to row 108 to produce my values.... can I break this up in anyway so that I can have like row 20 to 25 then also row 28 to 35 etc?
Thanks
Sub Products()
Dim wsFlatEstimates As Worksheet
Dim wsPO As Worksheet
Dim Lastrow As Long 'last populated row column C, products sheet
Dim i As Long 'loop variable
Dim PoRowCounter As Long 'row counter for PO sheet
Set wsFlatEstimates = Sheets("FlatEstimates")
Set wsPO = Sheets("PO")
'find last populated row, column C, product sheet
With wsFlatEstimates
Lastrow = .Range("C" & .Rows.Count).End(xlUp).Row
End With
wsPO.Select
Cells.EntireRow.Hidden = False
wsPO.Range("a18:j50").Select
Selection.ClearContents
PoRowCounter = 18 'row PoRowCounter PO sheet, assuming header row
'loop through products sheet
For i = 20 To 108
'check if column C is empty
If wsFlatEstimates.Range("C" & i).Value <> "" Then
PoRowCounter = PoRowCounter + 1
wsPO.Range("A" & PoRowCounter).Value = wsFlatEstimates.Range("c" & i).Value
wsPO.Range("c" & PoRowCounter).Value = wsFlatEstimates.Range("b" & i).Value
wsPO.Range("h" & PoRowCounter).Value = wsFlatEstimates.Range("d" & i).Value
End If
Next i
'tidy up and free memory
Set wsFlatEstimates = Nothing
End Sub
Im just wondering if anyone has a solution for this. In the code below I have a part with "for I = 20 to 108" which obviously uses the values from row 20 to row 108 to produce my values.... can I break this up in anyway so that I can have like row 20 to 25 then also row 28 to 35 etc?
Thanks
Sub Products()
Dim wsFlatEstimates As Worksheet
Dim wsPO As Worksheet
Dim Lastrow As Long 'last populated row column C, products sheet
Dim i As Long 'loop variable
Dim PoRowCounter As Long 'row counter for PO sheet
Set wsFlatEstimates = Sheets("FlatEstimates")
Set wsPO = Sheets("PO")
'find last populated row, column C, product sheet
With wsFlatEstimates
Lastrow = .Range("C" & .Rows.Count).End(xlUp).Row
End With
wsPO.Select
Cells.EntireRow.Hidden = False
wsPO.Range("a18:j50").Select
Selection.ClearContents
PoRowCounter = 18 'row PoRowCounter PO sheet, assuming header row
'loop through products sheet
For i = 20 To 108
'check if column C is empty
If wsFlatEstimates.Range("C" & i).Value <> "" Then
PoRowCounter = PoRowCounter + 1
wsPO.Range("A" & PoRowCounter).Value = wsFlatEstimates.Range("c" & i).Value
wsPO.Range("c" & PoRowCounter).Value = wsFlatEstimates.Range("b" & i).Value
wsPO.Range("h" & PoRowCounter).Value = wsFlatEstimates.Range("d" & i).Value
End If
Next i
'tidy up and free memory
Set wsFlatEstimates = Nothing
End Sub