Duffman4576
New Member
- Joined
- Sep 9, 2013
- Messages
- 21
Helllo again Forum: I have a macro that works, but when I added in a MSG box, I discovered something very strange. Right now the Macro updates pieces of infromation (those are the only thing population the I8 range in the Adjustments tab.)
By inserting the message box, I see that the Macro performs the updates on Name A and Name B, the does it to Name B four more times! - and scary enough, it swaps out Name B's info for Name A's info.
Utlimatly, the infromation is correct but this really shouldn't be happening.
Can anyone tell me why it is looping like this and why I get a total of six message box's to click through instead of two?
Sub More_Adjustments()
Dim rng As Range
Dim i As Integer
For i = 5 To 25
Dim cell As Range
Set rng = Sheets("Adjustments").Range("I8:I28")
On Error Resume Next
For Each cell In rng
If cell.Value = cell.Offset(1).Value And cell.Value > 0 Then
MsgBox ("You are about to make a change to " & cell.Offset(0, 1).Value)
cell.Offset(1, 2).Resize(1, 6).Copy
Sheets("Report").Select
Range(Sheets("Inputs").Range("I" & i).Value).Select
Selection.PasteSpecial xlPasteValues
Selection.Interior.Color = 65535
Sheets("Report").Range(Sheets("Inputs").Range("H" & i).Value).Interior.Color = 65535
i = i + 2
Else
End If
Next cell
Next i
End Sub
By inserting the message box, I see that the Macro performs the updates on Name A and Name B, the does it to Name B four more times! - and scary enough, it swaps out Name B's info for Name A's info.
Utlimatly, the infromation is correct but this really shouldn't be happening.
Can anyone tell me why it is looping like this and why I get a total of six message box's to click through instead of two?
Sub More_Adjustments()
Dim rng As Range
Dim i As Integer
For i = 5 To 25
Dim cell As Range
Set rng = Sheets("Adjustments").Range("I8:I28")
On Error Resume Next
For Each cell In rng
If cell.Value = cell.Offset(1).Value And cell.Value > 0 Then
MsgBox ("You are about to make a change to " & cell.Offset(0, 1).Value)
cell.Offset(1, 2).Resize(1, 6).Copy
Sheets("Report").Select
Range(Sheets("Inputs").Range("I" & i).Value).Select
Selection.PasteSpecial xlPasteValues
Selection.Interior.Color = 65535
Sheets("Report").Range(Sheets("Inputs").Range("H" & i).Value).Interior.Color = 65535
i = i + 2
Else
End If
Next cell
Next i
End Sub