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: 1
Default for..next statement problem


I`m having a bit of a problem with a for...next loop.
In the worksheet ive got a column which has a list of dates in.
What i need to do is for a form to pop-up and ask the user to ente
from which dates they would like the info to and from, then the othe
dates that are not in the range will all be deleted (the whole row
wiill be deleted) will all be deleted.

my code is as follows:
Private Sub CommandButton1_Click()

Dim date1 As Date

date1 = TextBox1.Text

Range("F9").Select 'select the first cell with the date in

For Each cell In ActiveCell.CurrentRegion.Cells

If ActiveCell = "" Then CommandButton2_Click
If ActiveCell < date1 Then ActiveCell.EntireRow.Delete
If ActiveCell date1 Then ActiveCell.Offset(1, 0).Activate

Next

End Sub

Private Sub CommandButton2_Click()

Dim date2 As Date

date2 = TextBox2.Text

Range("F9").Select

For Each cell In ActiveCell.CurrentRegion.Cells

If ActiveCell date2 Then ActiveCell.EntireRow.Delete
If ActiveCell < date2 Then ActiveCell.Offset(1, 0).Activate

Next

End Sub

What happens is, it just gets stuck into a continuous loop, and iv
tried loads of things, but still unable to make the loop somehow stop.

pls anyone help me on this! any help appreciated.

thank

--
s_ali_hassa
-----------------------------------------------------------------------
s_ali_hassan's Profile: http://www.excelforum.com/member.php...fo&userid=3532
View this thread: http://www.excelforum.com/showthread.php?threadid=55187

 
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 Manjit Gosal Excel Worksheet Functions 4 November 10th 05 05:40 PM
IF Statement problem trixma New Users to Excel 3 September 27th 05 06:36 AM
IF Statement Problem Bryan Excel Worksheet Functions 5 July 29th 05 04:10 PM
If Statement Problem Robert Hargreaves Excel Programming 2 May 29th 05 01:57 AM
Re - If Statement Problem Robert Hargreaves Excel Programming 0 May 28th 05 01:30 PM


All times are GMT +1. The time now is 09:06 AM.

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

About Us

"It's about Microsoft Excel"