Here is the code: The condition item is "If c.Offset(-8, 0).Value = T Then" which is not working. If I take this out, the code works perfectly and inserts the new columns.
Sub InsertCol()
Dim d As Range
Dim c As Range
Dim S As String
Dim T As String
Dim findAddress As String
Dim findAddress2 As String
T = InputBox("Which Sequence?")
On Error Resume Next
Select Case StrPtr(T)
Case 0
'OK not pressed
Exit Sub
Case Else
'OK pressed
'Carry on your routine, variable response contains the InputText
End Select
S = InputBox("Which Date?")
On Error Resume Next
Select Case StrPtr(S)
Case 0
'OK not pressed
Exit Sub
Case Else
'OK pressed
'Carry on your routine, variable response contains the InputText
End Select
With Worksheets("QRE Field Level").Range("A9:ON9")
Set c = .Find("*" & S & "*", LookIn:=xlValues)
If Not c Is Nothing Then findAddress = c.Address
If c.Offset(-8, 0).Value = T Then
Do
c.EntireColumn.Copy
c.EntireColumn.Insert Shift:=xlToRight
Application.CutCopyMode = False
c.Offset(0, 0) = Application.WorksheetFunction.EoMonth(c, 1)
c.Offset(201, 0) = c.Offset(0, 0)
c.Interior.Color = RGB(255, 0, 0)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> findAddress
End If
End With
End Sub
Bookmarks