Topic:Solved Problem with excel vba Remainpoint:0
   
PostTime:12/16/2008 7:20:23 PM FloorTop
Lv is 1
Avatar
Level:
1
Professional point:
46
Experience:
6
Thread:
265
Post:
966
Total online time:
6M
Joined date:
4/29/2007 12:00:00 AM
Last Visit:
12/17/2008 12:21:04 AM
Status:
Offline
Hi all,

I have a problem in removing certain rows in a file.
I have added the file with some information and color coded to wich has to be removed.
Some info: The data in the example is how i get it. I cant adjust it in the original file. I can play around with it by adding columns in wich i trim and such but i didnt get any results for the moment.

The thing it has to do is to delete the rows in wich the Time is after 17:59 and the date equals today - 1 (today = 31/10/2006 - 1 = 30/10/2006).

Thx for reading and the help in advance,

Stefan
 
     
   
Gender PostTime:12/16/2008 9:01:23 PM Point:0 | Floor# 1
Lv is 30Lv is 30Lv is 30Lv is 30
portrait
Level:
30
Professional point:
0
Experience:
27341
Thread:
272
Post:
945
Total online time:
27341M
Joined date:
4/24/2007 9:26:00 AM
Last Visit:
4/13/2009 10:45:15 PM
Status:
Offline
The sort order cant be changed because the structure from the file is that it is taken from a txt file. Then certain data is trimmed out and then sorted on a perticular value we need to proceed to the next part of the whole proces.

The rows depend but its never too high. Lets say a maximum of 200 rows.
 
     
   
Gender PostTime:12/16/2008 9:13:22 PM Point:0 | Floor# 2
Lv is 1
portrait
Level:
1
Professional point:
48
Experience:
8
Thread:
292
Post:
962
Total online time:
8M
Joined date:
4/28/2007 11:08:00 PM
Last Visit:
12/17/2008 12:44:40 AM
Status:
Offline
How do i do that? :shame:

Edit: Fine now, it all works.
 
     
   
Gender PostTime:12/16/2008 10:45:18 PM Point:0 | Floor# 3
Lv is 1
portrait
Level:
1
Professional point:
38
Experience:
20
Thread:
263
Post:
936
Total online time:
20M
Joined date:
4/28/2007 10:44:00 PM
Last Visit:
12/17/2008 12:58:22 AM
Status:
Offline
Can you mark the thread as a solved please?
 
     
   
Gender PostTime:12/16/2008 10:56:55 PM Point:0 | Floor# 4
Lv is 1
portrait
Level:
1
Professional point:
46
Experience:
1
Thread:
287
Post:
926
Total online time:
1M
Joined date:
4/28/2007 11:03:00 PM
Last Visit:
12/17/2008 12:22:57 AM
Status:
Offline
Sub test()
For Each Cell In Range("A1", Range("A1").End(xlDown))
If Left(WorksheetFunction.Trim(Cell), 2) > 17 Then
If WorksheetFunction.Trim(Cell.Offset(0, 1)) < Date Then
Cell.Offset(0, 2) = "X"
End If
End If
Next Cell

Columns(3).SpecialCells(xlCellTypeConstants, 23).EntireRow.Delete
End Sub
 
     
   
Gender PostTime:12/16/2008 11:17:08 PM Point:0 | Floor# 5
Lv is 1
portrait
Level:
1
Professional point:
46
Experience:
6
Thread:
265
Post:
966
Total online time:
6M
Joined date:
4/29/2007 12:00:00 AM
Last Visit:
12/17/2008 12:21:04 AM
Status:
Offline
He does it like i wanted except that if the last row is date - 1 he doesnt do it.

If you put in my example everything in the correct columns and then change the last one or two rows of date to 30/10/2006 he doesnt remove the last one?

Referring to the code of OBP :-)

Tested the code of bomb and that one works. Im gonna test it now on the original file to see how it goes. Ill let you know something in a few.
 
     
   
Gender PostTime:12/16/2008 11:35:59 PM Point:0 | Floor# 6
Lv is 1
portrait
Level:
1
Professional point:
5
Experience:
19
Thread:
290
Post:
993
Total online time:
19M
Joined date:
4/28/2007 11:08:00 PM
Last Visit:
12/17/2008 12:44:18 AM
Status:
Offline
I tried the trim thing, but the result is that it doesnt look at the cell in time format then.
When i trim it the space is gone but it sillt isnt formatted as time. Thats why i posted it cause i couldnt find a solution for that problem. When i trimmed the space was gone and the cell looked like hour but it wasnt formatted like it.
 
     
   
Gender PostTime:12/17/2008 12:11:47 AM Point:0 | Floor# 7
Lv is 1
portrait
Level:
1
Professional point:
10
Experience:
14
Thread:
278
Post:
973
Total online time:
14M
Joined date:
4/28/2007 11:18:00 PM
Last Visit:
12/17/2008 12:41:03 AM
Status:
Offline
Can you tell me if the data is in the actual columns as shown?

The data is as shown, i just copyd a part of the column from the original file to show an example. If you wanna know about the column name, its different, the columns in the orignal file are Time = column R and Date = column S with the name of the column on the first row.

Can you tell me the last rightmost column of your data as the VBA will be much quicker if the data is sorted by date and then time before the deletions are made?

The last column on the original file is S, the date column. The data isnt sorted by date and hour, it sorted by another value. That cant be changed also.
 
     
   
Gender PostTime:12/17/2008 12:28:11 AM Point:0 | Floor# 8
Lv is 1
portrait
Level:
1
Professional point:
17
Experience:
7
Thread:
282
Post:
954
Total online time:
7M
Joined date:
4/28/2007 11:52:00 PM
Last Visit:
12/17/2008 12:05:13 AM
Status:
Offline
The format doesn't make it a date or time see the code above where it is set to a date variable.
 
     
   
Gender PostTime:12/17/2008 12:42:12 AM Point:0 | Floor# 9
Lv is 1
portrait
Level:
1
Professional point:
78
Experience:
9
Thread:
286
Post:
947
Total online time:
9M
Joined date:
4/29/2007 12:17:00 AM
Last Visit:
12/16/2008 11:26:07 PM
Status:
Offline
Little update:

The code of OBP works now also on the last row and the code of bomb works but removes also the dates below 30/10/2006. My bad for not giving enough information cause it only has to delete the date -1, so today only 30/10/2006.

Thx alot for the help guys, in case of further problems ill get back to you

But for now all is ok, thx.
 
     
   
Gender PostTime:12/17/2008 12:58:05 AM Point:0 | Floor# 10
Lv is 1
portrait
Level:
1
Professional point:
62
Experience:
12
Thread:
287
Post:
938
Total online time:
12M
Joined date:
4/29/2007 2:35:00 AM
Last Visit:
12/17/2008 12:42:43 AM
Status:
Offline
Works on mine?
 
     
1

Sorry, you are not login, click here to login

 

About us | Advertise | Contact us | Partner | Bug Report|Suggesting box|Donation
Home | Forum | Affiliate program| Remote help | Setting | Search | Document | Help | Download|Message

 

Start new topicAdvanced search