Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Removing rows based on isDate

Ok, I had posted questions on how to do all of this a couple of days ago, and
my post has gotten lost in the mix. With some help, and playing around, I
have acheived my goal of converting 1st set of data below to the 2nd set of
data.
What I want to do now is to remove the rows in which a date "isDate" resides
in a cell in column A. Any help or clean up on what I have would be greatly
appreciated.

Thanks,

Matt


1st
A B
---------------
Fri Oct 19
data
data
data
..
..
..
Thu Oct 18
data
data
data
..
..
..




2nd
A B
-------------------
10/19/2007
data 10/19/2007
data 10/19/2007
data 10/19/2007
data 10/19/2007
..
..
..
10/18/2007
data 10/18/2007
data 10/18/2007
data 10/18/2007
data 10/18/2007
data 10/18/2007
..
..
..




Sub rm_blnk_lns()
' #####################
' This part removes all blank rows
' #####################
Dim Row As Long

Application.ScreenUpdating = False
With ActiveSheet
For Row = .UsedRange.Row + .UsedRange.Rows.Count - 1 To .UsedRange.Row
Step -1
If Application.CountA(.Rows(Row)) = 0 Then .Rows(Row).Delete
Next Row
End With
Application.ScreenUpdating = True

' ###############################################
' This part goes and changes all of the dates from the format Mon Oct 18 to
just Oct 18
' ###############################################

Range("A:A").Select
Cells.Replace What:="Mon ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Tue ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Wed ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Thu ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Fri ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Sat ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Sun ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

' ################################################
' This part actually formats the date from Oct 18 to 10/18/2007
' ################################################
Dim D As Date
For Each c In Range("A:A")
If IsDate(c) Then
c.NumberFormat = "m/d/yyyy;@"
c.Offset(1, 1).Value = c.Value
D = c.Value
' .Rows(c).Delete
Else
If c.Value = "" Then
' do nothing
Else
c.Offset(0, 1).Value = D
End If
End If
Next

'################################################# ##
' This part removes all of the hyperlinks from the data
'################################################# ##

Range("A:B").Select
Selection.Hyperlinks.Delete

' ##################################################
' This part autofits columns A & B and removes all borders
' ##################################################

Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit

Range("A:B").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Font.Bold = False

Columns("A:B").Select
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Application.ScreenUpdating = False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Removing rows based on isDate

LastRow = cells(Rows.Count,"A").end(xlup).Row
For RowCount = LastRow to 1 step -1

if isdate(cells(RowCount,"A")) then
Rows(RowCount).delete
end if
next RowCount

"Matt P." wrote:

Ok, I had posted questions on how to do all of this a couple of days ago, and
my post has gotten lost in the mix. With some help, and playing around, I
have acheived my goal of converting 1st set of data below to the 2nd set of
data.
What I want to do now is to remove the rows in which a date "isDate" resides
in a cell in column A. Any help or clean up on what I have would be greatly
appreciated.

Thanks,

Matt


1st
A B
---------------
Fri Oct 19
data
data
data
.
.
.
Thu Oct 18
data
data
data
.
.
.




2nd
A B
-------------------
10/19/2007
data 10/19/2007
data 10/19/2007
data 10/19/2007
data 10/19/2007
.
.
.
10/18/2007
data 10/18/2007
data 10/18/2007
data 10/18/2007
data 10/18/2007
data 10/18/2007
.
.
.




Sub rm_blnk_lns()
' #####################
' This part removes all blank rows
' #####################
Dim Row As Long

Application.ScreenUpdating = False
With ActiveSheet
For Row = .UsedRange.Row + .UsedRange.Rows.Count - 1 To .UsedRange.Row
Step -1
If Application.CountA(.Rows(Row)) = 0 Then .Rows(Row).Delete
Next Row
End With
Application.ScreenUpdating = True

' ###############################################
' This part goes and changes all of the dates from the format Mon Oct 18 to
just Oct 18
' ###############################################

Range("A:A").Select
Cells.Replace What:="Mon ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Tue ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Wed ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Thu ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Fri ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Sat ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

Range("A:A").Select
Cells.Replace What:="Sun ", Replacement:="", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False

' ################################################
' This part actually formats the date from Oct 18 to 10/18/2007
' ################################################
Dim D As Date
For Each c In Range("A:A")
If IsDate(c) Then
c.NumberFormat = "m/d/yyyy;@"
c.Offset(1, 1).Value = c.Value
D = c.Value
' .Rows(c).Delete
Else
If c.Value = "" Then
' do nothing
Else
c.Offset(0, 1).Value = D
End If
End If
Next

'################################################# ##
' This part removes all of the hyperlinks from the data
'################################################# ##

Range("A:B").Select
Selection.Hyperlinks.Delete

' ##################################################
' This part autofits columns A & B and removes all borders
' ##################################################

Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit

Range("A:B").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Font.Bold = False

Columns("A:B").Select
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Application.ScreenUpdating = False
End Sub

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
IsDate? Arne Hegefors Excel Worksheet Functions 3 January 30th 07 01:44 PM
cut rows from worksheet based on cell isdate value rod Excel Programming 0 October 19th 06 04:37 AM
IsDate april27 Excel Programming 9 June 16th 06 02:14 PM
vba: isDate function phil Excel Programming 1 February 2nd 06 04:28 AM
Removing Empty Rows and selecting Specific Rows Jetheat[_8_] Excel Programming 7 August 12th 05 12:10 AM


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