Dan Pilgrim
New Member
- Joined
- Dec 4, 2014
- Messages
- 5
A | B | C | D | E | F | G | H | I | J | K | L | |
1 | ||||||||||||
2 | 661 | Delete | Item | 809 | Dan | Pilgrim | 3 | 280 | ||||
3 | 721 | Delete | Matrix | 809 | Dan | Pilgrim | 3 | 280 | ||||
4 | 727 | Amend | Matrix | - | Cr | Int | Det | 809 | Dan | Pilgrim | 3 | 280 |
5 | ||||||||||||
6 |
<tbody>
</tbody>
Hi all,
I've been considering this for days and have now given up. I have a spreadsheet much like the one above and I'm trying to develop a macro to insert 4 cells from column D based on the value of column A.
I've come up with the following so far, and know it doesn't do it from D, but get a Run-time error '1004'. Please help.
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "A")
If Not IsError(.Value) Then
If .Value = "661" Or "721" Then .Insert Shift:=x4ToRight, CopyOrigin:=xlFormatFromLeftOrAbove
End If
End With
Next Lrow
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub