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: 18
Default If Statement Problem

I have changed my code to the same as at the bottom of the page but have 2
issue with the code. I cant specify * as a year for all date find criteria
as the code doesn't allow for this. How could I change the code to allow
for all the 2005's to be replaced with a wildcard.

I also need to add a month to the end of the sheet but depending on which
month it is that is removed there will be a different range. I have written
some code to find the first empty cell which works but arent sure how to
modify a line to use activecell as the variable for adding a new month.

Heres the code

The code for delete is like this.

If ActiveSheet.Range("$A$4").Value = #1/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4").Value = #2/1/2008# Then
ActiveSheet.Rows("4:32").Delete
ElseIf ActiveSheet.Range("$A$4").Value = #2/1/2012# Then
ActiveSheet.Rows("4:32").Delete
ElseIf ActiveSheet.Range("$A$4").Value = #2/1/2016# Then
ActiveSheet.Rows("4:32").Delete
ElseIf ActiveSheet.Range("$A$4") = #2/1/2005# Then
ActiveSheet.Rows("4:31").Delete
ElseIf ActiveSheet.Range("$A$4") = #3/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4") = #4/1/2005# Then
ActiveSheet.Rows("4:33").Delete
ElseIf ActiveSheet.Range("$A$4") = #5/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4") = #6/1/2005# Then
ActiveSheet.Rows("4:33").Delete
ElseIf ActiveSheet.Range("$A$4") = #7/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4") = #8/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4") = #9/1/2005# Then
ActiveSheet.Rows("4:33").Delete
ElseIf ActiveSheet.Range("$A$4") = #10/1/2005# Then
ActiveSheet.Rows("4:34").Delete
ElseIf ActiveSheet.Range("$A$4") = #11/1/2005# Then
ActiveSheet.Rows("4:33").Delete
ElseIf ActiveSheet.Range("$A$4") = #12/1/2005# Then
ActiveSheet.Rows("4:34").Delete
End If

The code for add would be something like this -

Range("A1").Select

Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If

Loop Until IsEmpty(ActiveCell) = True

'This is where I am stuck....

'Range("A5:A6").AutoFill Destination:=Range("A5:A9") - Recommended code to
autofill

'Range(ActiveCell:Activecell - 1).Autofill
Destination:=Range("ActiveCell:????) - code modified to use autofil as
variable which doesnt work.

End Sub

Thanks
Rob





 
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 problem webstju Excel Worksheet Functions 3 April 21st 06 12:58 PM
IF Statement problem trixma New Users to Excel 3 September 27th 05 06:36 AM
IF Statement Problem No Name Excel Programming 3 March 2nd 05 11:21 PM
Problem with if statement Marie Excel Programming 13 February 7th 05 01:25 AM
I have an "IF"Statement problem...please help!! cmk0007 Excel Worksheet Functions 1 November 5th 04 01:24 AM


All times are GMT +1. The time now is 04:43 AM.

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"