PDA

View Full Version : Shift if "Invoice Date"



Djblois
01-29-2007, 02:53 PM
I am trying to shift data over if column "G" says "Invoice Date". This is the code I am using and currently it is not working:

For i = 1 To finalRow
If Cells(i, "G") = "Off-Invoice" Then
Range("I" & i).Insert shift:=xlToRight
Range("J" & i).Insert shift:=xlToRight
Range("K" & i).Insert shift:=xlToRight
End If
Next

Bob Phillips
01-29-2007, 03:04 PM
For i = 1 To finalRow
If Cells(i, "G") = "Off-Invoice" Then
Range("K" & i).Insert shift:=xlToRight
Range("J" & i).Insert shift:=xlToRight
Range("I" & i).Insert shift:=xlToRight
End If
Next

Halldo
01-29-2007, 03:07 PM
Try this modified code.


For i = 1 To finalRow
If Cells(i, 7) = "Off-Invoice" Then
Range("I" & i).Insert shift:=xlToRight
Range("J" & i).Insert shift:=xlToRight
Range("K" & i).Insert shift:=xlToRight
End If
Next

Djblois
01-29-2007, 03:08 PM
Thank you but that wouldn't work right because I technically need to move the I column over 3 columns. Right now it isn't moving them at all. I should have told you that before.

Bob Phillips
01-29-2007, 03:12 PM
Did for me.

I assumed you wanted blanks between.

If you 3 extra cilumns before i, then use



For i = 1 To finalRow
If Cells(i, "G") = "Off-Invoice" Then
Range("I" & i).Resize(, 3).Insert shift:=xlToRight
End If
Next