LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default If Statement with variables

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement with two variables RoadKill Excel Worksheet Functions 9 April 4th 23 12:47 PM
how do i if statement for 3 variables wheefus Excel Worksheet Functions 7 December 17th 07 07:26 PM
Too many variables for an if than statement? repke New Users to Excel 3 May 2nd 06 05:01 PM
Use variables in sql statement Markantesp Excel Programming 2 March 8th 05 08:15 PM
Variables in a Range statement ChuckM[_2_] Excel Programming 1 December 15th 03 04:16 PM


All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"