Q
qerj
I have been at this problem for too long...keep not getting the
results I need. I have a wks (ie: wks1) that has a commandbutton on
it that copies a 2nd wks (ie: wks2) to a 3rd (ie: wks3) so that I can
delete some rows not needed for a report and re-sort based on data in
1 column. The copy procedure works fine but when it looks thru the
data in column D for the string "series", it does not delete the rows.
The secondary procedure to sort works fine. What am I doing wrong?
Please Help...thx
here is the code for both steps:
Sub btnSortBySRC_Click()
Dim strMainWks As String
Dim strTmpWks As String
Dim wsCurWks As Worksheet
Dim rSortRange As Range
TakeFocusOnClick = False
strMainWks = "Main Data"
strTmpWks = "Sort Workspace by SRC"
ActiveWorkbook.Sheets(strMainWks).Activate
Sheets(strMainWks).Copy After:=Sheets(strMainWks)
ActiveSheet.Name = strTmpWks
Set wsCurWks = ActiveSheet
sDeleteSeriesHdr
wsCurWks.Columns("A:B").Delete 'delete 2 unwanted columns
Set rSortRange = wsCurWks.Range("A:U")
rSortRange.Sort Key1:=rSortRange.Columns(10), Order1:=xlAscending
End Sub
Sub sDeleteSeriesHdr() 'delete series header row
Dim rMyRange As Range
Dim rMyCell As Range
Dim rMyDeletion As Range
Application.ScreenUpdating = False
Set rMyRange = Range("d1:d150") ' check specific number of rows
For Each rMyCell In rMyRange
If InStr(rMyCell.Text, "Series") > 0 Then
'MsgBox ActiveCell.Text
If rMyDeletion Is Nothing Then
Set rMyDeletion = rMyCell
Else
Set rMyDeletion = Union(rMyCell, rMyDeletion)
End If
End If
Next
If Not (rMyDeletion Is Nothing) Then
rMyDeletion.EntireRow.Delete
End If
Application.ScreenUpdating = True
End Sub
results I need. I have a wks (ie: wks1) that has a commandbutton on
it that copies a 2nd wks (ie: wks2) to a 3rd (ie: wks3) so that I can
delete some rows not needed for a report and re-sort based on data in
1 column. The copy procedure works fine but when it looks thru the
data in column D for the string "series", it does not delete the rows.
The secondary procedure to sort works fine. What am I doing wrong?
Please Help...thx
here is the code for both steps:
Sub btnSortBySRC_Click()
Dim strMainWks As String
Dim strTmpWks As String
Dim wsCurWks As Worksheet
Dim rSortRange As Range
TakeFocusOnClick = False
strMainWks = "Main Data"
strTmpWks = "Sort Workspace by SRC"
ActiveWorkbook.Sheets(strMainWks).Activate
Sheets(strMainWks).Copy After:=Sheets(strMainWks)
ActiveSheet.Name = strTmpWks
Set wsCurWks = ActiveSheet
sDeleteSeriesHdr
wsCurWks.Columns("A:B").Delete 'delete 2 unwanted columns
Set rSortRange = wsCurWks.Range("A:U")
rSortRange.Sort Key1:=rSortRange.Columns(10), Order1:=xlAscending
End Sub
Sub sDeleteSeriesHdr() 'delete series header row
Dim rMyRange As Range
Dim rMyCell As Range
Dim rMyDeletion As Range
Application.ScreenUpdating = False
Set rMyRange = Range("d1:d150") ' check specific number of rows
For Each rMyCell In rMyRange
If InStr(rMyCell.Text, "Series") > 0 Then
'MsgBox ActiveCell.Text
If rMyDeletion Is Nothing Then
Set rMyDeletion = rMyCell
Else
Set rMyDeletion = Union(rMyCell, rMyDeletion)
End If
End If
Next
If Not (rMyDeletion Is Nothing) Then
rMyDeletion.EntireRow.Delete
End If
Application.ScreenUpdating = True
End Sub