If Rows("1").Select < mthone Or mthtwo Or mththree Or mthfour Or "" Or
"Name" Then
would have to be something like
set rng = Cells(1,256).End(xltoLeft)
for each i = rng.column to 1 step -1
set cell = cells(1,i)
if cell<"" and lcase(cell) < "name" then
s = lcase(format(cell,"mmm-yy"))
if s < lcase(mthone) and s < lcase(mthtwo) _
and s < lcase(mththree) and s < lcase(mthfour) then
cell.EntireColumn.Delete
end if
end if
Next
--
Regards,
Tom Ogilvy
"Neutron1871" wrote in message
...
I am trying to figure out how to make the below VB run correctly. This
code
selects row 1 and then based on what is in each cell, deletes any column
that
does not have 1 of 4 variables, is not blank, and does not contain the
word
"Name". Please help!!
' If statement to ask user what months are being reported on and formats
accordingly.
mthcount = InputBox("Enter # of Months to Report", "Rpt Mths #")
If mthcount = 2 Then
mthone = InputBox("Enter First Reporting Month (mmm-yy)", "Rpt Mth
1")
mthtwo = InputBox("Enter Second Reporting Month (mmm-yy)", "Rpt Mth
2")
ElseIf mthcount = 3 Then
mthone = InputBox("Enter First Reporting Month (mmm-yy)", "Rpt Mth
1")
mthtwo = InputBox("Enter Second Reporting Month (mmm-yy)", "Rpt Mth
2")
mththree = InputBox("Enter Third Reporting Month (mmm-yy)", "Rpt
Mth
3")
ElseIf mthcount = 4 Then
mthone = InputBox("Enter First Reporting Month (mmm-yy)", "Rpt Mth
1")
mthtwo = InputBox("Enter Second Reporting Month (mmm-yy)", "Rpt Mth
2")
mththree = InputBox("Enter Third Reporting Month (mmm-yy)", "Rpt
Mth
3")
mthfour = InputBox("Enter Fourth Reporting Month (mmm-yy)", "Rpt
Mth
4")
End If
Rows("1").Select
If Rows("1").Select < mthone Or mthtwo Or mththree Or mthfour Or "" Or
"Name" Then
Column.Delete
End If