allow breaks in my code?

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
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
 
Just had another thought, is there any way to determine which rows to skip?
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
hi Norie good to see you still on here :)

no the rows are totally random... no sequence to them at all

I mean I can tell you based on what the spreadsheet is now exactly which rows... ut its not like its every 7th or anything like that
 
Last edited:
Upvote 0
I wasn't really looking for a sequence/pattern, just some sort of criteria.

For example, do you want to ignore rows that don't have a particular search term on them?

Do you want to ignore rows that have a blank in column X?

etc
 
Upvote 0
I wasn't really looking for a sequence/pattern, just some sort of criteria.

For example, do you want to ignore rows that don't have a particular search term on them?

Do you want to ignore rows that have a blank in column X?

etc

Hi Norie... actually yes... we could ignore anything with text and only pull from the cells with numbers in them.

Ken
 
Upvote 0

Forum statistics

Threads
1,214,974
Messages
6,122,536
Members
449,088
Latest member
RandomExceller01

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