ClimoC
Well-known Member
- Joined
- Aug 21, 2009
- Messages
- 584
Hey guys.
I've been racking my brain over this for 2 days now, and I think my code simply won't do the trick.
What I have is a table in one sheet, which I want to 'break up' into chunks as it is pasted into a second sheet.
What I've been doing is copying the item to the sheet, then using offsets to put in all the little bits around that item, then the next one should start between 8 and 12 rows later than the previous one (depending on a 2 option variable). Problem is, it will paste the cell value to the sheet2, then add the bits it needs to with offsets, but the next pass it does it either pastes over the top of the previous one, or in the row directly beneath it.
I've tried it with "For each" and "For x = 1 to lastr" and neither seem to be quite doing it.
Here is the code in its current state.
Can anyone suggest a nice, easy way of doing this?
Also - the first 'Find' function (if the first if statement returns true) works fine, over and over. The first time it gets 'false' and goes to the 'else' argument, THAT find doesn't work.
I've been racking my brain over this for 2 days now, and I think my code simply won't do the trick.
What I have is a table in one sheet, which I want to 'break up' into chunks as it is pasted into a second sheet.
What I've been doing is copying the item to the sheet, then using offsets to put in all the little bits around that item, then the next one should start between 8 and 12 rows later than the previous one (depending on a 2 option variable). Problem is, it will paste the cell value to the sheet2, then add the bits it needs to with offsets, but the next pass it does it either pastes over the top of the previous one, or in the row directly beneath it.
I've tried it with "For each" and "For x = 1 to lastr" and neither seem to be quite doing it.
Here is the code in its current state.
Code:
Sub bobbins()
Dim range1 As range
Dim range2 As range
Dim lastr1 As Integer
Dim lastr2 As Integer
Dim gapsize As Integer
Sheets("schedule_info2").Activate
Set range1 = range("E2", range("E65000").End(xlUp))
lastr1 = range("E65000").End(xlUp).Row
Sheets("Channel1").Activate
Set range2 = range("c9", range("c65000").End(xlUp))
lastr2 = range("C65000").End(xlUp).Row
For x = 2 To lastr2 Step 1
If Sheets("schedule_info2").range("C" & x).Offset(, 2).Value < 0.021 And Sheets("schedule_info2").range("C" & x).Offset(0, -1).Value >= 0.708 Then
Sheets("Channel1").Activate
range2.Find(What:="", LookIn:= _
xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, searchdirection:= _
xlNext, MatchCase:=True, SearchFormat:=True).Activate
If ActiveCell.Offset(-1, 2).Value < 0.021 Then
gapsize = 8
ElseIf ActiveCell.Offset(-1, 2).Value > 0.021 Then
gapsize = 12
End If
pasterow = ActiveCell.Row + gapsize
range("C" & pasterow).Value = Sheets("schedule_info2").range("C" & x).Value
range("B" & pasterow).Value = Sheets("schedule_info2").range("C" & x).Offset(0, -1).Value
range("A" & pasterow - 1).Value = Sheets("schedule_info2").range("C" & x).Offset(0, -2).Value
range("D" & pasterow).Value = "Intro"
range("D" & pasterow + 1).Value = "IPPSOP1"
range("D" & pasterow + 2).Value = "IPPEOP1"
range("D" & pasterow + 3).Value = "15' Menu"
range("D" & pasterow + 4).Value = "IPPSOLP"
range("D" & pasterow + 5).Value = "IPPEOLP"
range("D" & pasterow + 6).Value = "End Credit"
ElseIf Sheets("schedule_info2").range("C" & x).Offset(, 2).Value > 0.021 And Sheets("schedule_info2").range("C" & x).Offset(0, -1).Value >= 0.708 Then
Sheets("Channel1").Activate
range2.Find(What:="", LookIn:= _
xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, searchdirection:= _
xlNext, MatchCase:=True, SearchFormat:=True).Select
If ActiveCell.Offset(-1, 2).Value < 0.021 Then
gapsize = 8
ElseIf ActiveCell.Offset(-1, 2).Value > 0.021 Then
gapsize = 12
End If
pasterow = ActiveCell.Row
range("C" & pasterow).Value = Sheets("schedule_info2").range("C" & x).Value
range("B" & pasterow).Value = Sheets("schedule_info2").range("C" & x).Offset(0, -1).Value
range("A" & pasterow - 1).Value = Sheets("schedule_info2").range("C" & x).Offset(0, -2).Value
range("D" & pasterow).Value = "Intro"
range("D" & pasterow + 1).Value = "IPPSOP1"
range("D" & pasterow + 2).Value = "IPPEOP1"
range("D" & pasterow + 3).Value = "IPPSOP2"
range("D" & pasterow + 4).Value = "IPPEOP2"
range("D" & pasterow + 5).Value = "IPPSOP3"
range("D" & pasterow + 6).Value = "IPPEOP3"
range("D" & pasterow + 7).Value = "15' Menu"
range("D" & pasterow + 8).Value = "IPPSOLP"
range("D" & pasterow + 9).Value = "IPPEOLP"
range("D" & pasterow + 10).Value = "End Credit"
Else
End If
Next x
End Sub
Can anyone suggest a nice, easy way of doing this?
Also - the first 'Find' function (if the first if statement returns true) works fine, over and over. The first time it gets 'false' and goes to the 'else' argument, THAT find doesn't work.