Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Remove rows in huge data array

Hi,

I need some help with VBA programming. I have a huge array with financial
data: daily data for 7 last years. The first column (A:A) in the array is
dates in format dd.mm.yyyy, next few columns contains different data. What I
need is to go through dates, find weekends and delete rows with weekends (not
just clear content of rows but delete/cut them).

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Remove rows in huge data array

Try this:

Sub noweekend()
Dim n As Long, d As Date
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = n To 1 Step -1
d = Cells(i, 1).Value
dayIs = Format(d, "ddd")
If dayIs = "Sat" Or dayIs = "Sun" Then
Cells(i, 1).EntireRow.Delete
End If
Next
End Sub

This assumes that the values are "real" dates.
--
Gary''s Student - gsnu200830


"Artem" wrote:

Hi,

I need some help with VBA programming. I have a huge array with financial
data: daily data for 7 last years. The first column (A:A) in the array is
dates in format dd.mm.yyyy, next few columns contains different data. What I
need is to go through dates, find weekends and delete rows with weekends (not
just clear content of rows but delete/cut them).

Thanks in advance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Remove rows in huge data array

Give this a try:

Sub Titles()
Dim lr As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
With ActiveSheet
weDay = Format(.Cells(i, 1).Value, "w")
If weDat = 1 Or weDay = 7 Then
.Cells(i, 1).EntireRow.Delete
End If
End With
Next
End Sub





"Artem" wrote:

Hi,

I need some help with VBA programming. I have a huge array with financial
data: daily data for 7 last years. The first column (A:A) in the array is
dates in format dd.mm.yyyy, next few columns contains different data. What I
need is to go through dates, find weekends and delete rows with weekends (not
just clear content of rows but delete/cut them).

Thanks in advance!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Remove rows in huge data array

Thanks, but it doesn't work for me. Nothing happens then I'm running the
macro. What does "real date" mean? I've just used date format for the date
column, is it enough? I'musing Office 2007 btw.

"Gary''s Student" wrote:

Try this:

Sub noweekend()
Dim n As Long, d As Date
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = n To 1 Step -1
d = Cells(i, 1).Value
dayIs = Format(d, "ddd")
If dayIs = "Sat" Or dayIs = "Sun" Then
Cells(i, 1).EntireRow.Delete
End If
Next
End Sub

This assumes that the values are "real" dates.
--
Gary''s Student - gsnu200830


"Artem" wrote:

Hi,

I need some help with VBA programming. I have a huge array with financial
data: daily data for 7 last years. The first column (A:A) in the array is
dates in format dd.mm.yyyy, next few columns contains different data. What I
need is to go through dates, find weekends and delete rows with weekends (not
just clear content of rows but delete/cut them).

Thanks in advance!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Remove rows in huge data array

It works but partly. Macro removed all Saturdays but not Sundays:-( I'm using
Office 2007, btw.

Thanks.


"JLGWhiz" wrote:

Give this a try:

Sub Titles()
Dim lr As Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
With ActiveSheet
weDay = Format(.Cells(i, 1).Value, "w")
If weDat = 1 Or weDay = 7 Then
.Cells(i, 1).EntireRow.Delete
End If
End With
Next
End Sub





"Artem" wrote:

Hi,

I need some help with VBA programming. I have a huge array with financial
data: daily data for 7 last years. The first column (A:A) in the array is
dates in format dd.mm.yyyy, next few columns contains different data. What I
need is to go through dates, find weekends and delete rows with weekends (not
just clear content of rows but delete/cut them).

Thanks in advance!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Remove rows in huge data array

If weDay = 1 Or weDay = 7 Then
--
Gary''s Student - gsnu2007k
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Remove rows in huge data array

I'm feeling myself completely stupid:-)

Thanks a lot both of you!!! You saved me lots of time.


"Gary''s Student" wrote:

If weDay = 1 Or weDay = 7 Then
--
Gary''s Student - gsnu2007k

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Remove rows in huge data array

Thanks GS, someone needs to come up with a spell check for VBA. I suppose
Option Explicit would have caught that.

"Gary''s Student" wrote:

If weDay = 1 Or weDay = 7 Then
--
Gary''s Student - gsnu2007k

Reply
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
How do I remove/edit a huge page number in the middle of a workshe dns324 Excel Discussion (Misc queries) 3 June 2nd 09 03:30 PM
"Add/Remove Rows Code" adds rows on grouped sheets, but won't remove rows. Conan Kelly Excel Programming 1 November 16th 07 10:41 PM
Remove Blank and Non Data Rows UT Excel Discussion (Misc queries) 3 June 12th 07 10:01 PM
Introducing rows in between every observation for huge panel data sets. [email protected] Excel Programming 2 May 22nd 07 01:22 PM
How to conditionally remove rows with data wmc Excel Worksheet Functions 0 February 27th 07 10:44 PM


All times are GMT +1. The time now is 06:34 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"