Riddlemethis
New Member
- Joined
- Apr 20, 2021
- Messages
- 14
- Office Version
- 2013
- Platform
- Windows
Script below:
Dim rng As Range
Set rng = Range("BJ5:BJ500")
Sheets("Daily Runboard").Activate
For Each cell In rng
If cell.Value = "MCC" Then
cell.Select
ActiveCell.Offset(0, -59).Select
ActiveCell.Resize(11, 22).Copy
Sheets("H Runs").Select
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveCell.PasteSpecial xlPasteValues
ActiveCell.PasteSpecial xlPasteFormats
End If
Next
End Sub
So works perfectly at the first cell.value match in the range where it selects the cell, offsets where i need it too, changes range size, copy's, move sheets and pastes correctly ( text and format) too the next relevant empty cell in the sheet i need it too. Problem being it seems to circle the loop but not go down the range correctly after the first cycle where it works OK.. After the first match it seems to cycle through where it no longer meets the correct cell.value but yet it should?
In this specific data dump the next cells down is blank in the range all the way down to where the next cell in BJ5:BJ500 with a vlaue also contains the correct cell.value "MCC" but it passes through the loop when I step by step it as in it doesn't reference the other cells in the rng
What am i doing wrong?
Dim rng As Range
Set rng = Range("BJ5:BJ500")
Sheets("Daily Runboard").Activate
For Each cell In rng
If cell.Value = "MCC" Then
cell.Select
ActiveCell.Offset(0, -59).Select
ActiveCell.Resize(11, 22).Copy
Sheets("H Runs").Select
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveCell.PasteSpecial xlPasteValues
ActiveCell.PasteSpecial xlPasteFormats
End If
Next
End Sub
So works perfectly at the first cell.value match in the range where it selects the cell, offsets where i need it too, changes range size, copy's, move sheets and pastes correctly ( text and format) too the next relevant empty cell in the sheet i need it too. Problem being it seems to circle the loop but not go down the range correctly after the first cycle where it works OK.. After the first match it seems to cycle through where it no longer meets the correct cell.value but yet it should?
In this specific data dump the next cells down is blank in the range all the way down to where the next cell in BJ5:BJ500 with a vlaue also contains the correct cell.value "MCC" but it passes through the loop when I step by step it as in it doesn't reference the other cells in the rng
What am i doing wrong?
Last edited: