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: 12
Default Macro Help, Please



A workbook contains three worksheets: (1) "Server Delete List", (2) "Data
Processing Sheet" and (3) "Loadlist Processing". The code is run from a
control button on "Server Delete List" worksheet (Sheet 1). That code runs
fine in processing data on the "Data Processing Sheet" (Sheet 2).

On Sheet 3, the code deletes entire rows based on several criteria:
duplicate numbers, cells containing the strings "Digibeta" and "Record". It
runs fine in processing the duplicate number row delete function code on the
"Loadlist Processing" worksheet (Sheet 3). But, it fails when trying to run
the "Digibeta" and "Record" row delete code on Sheet 3.

I should note that both the "Digibeta" and "Record" row delete code runs
fine when run from a macro created on and run from Sheet 3. So, I suspect
that I have omitted one or more references to Sheet 3 ("Loadlist
Processing") in the code that runs from Sheet 1 for these two operations.
But, I can't figure out what!

Any suggestions would be most welcomed.

Thanks and regards,

PJF
__________________________________________________ ____________________
Here is the relevant code:

Sheets("LoadList Processing").Select '(Sheet 3)



ActiveSheet.Range(Selection, "A1:A1000").Select



Dim Col As Integer

Dim r As Long

Dim C As Range

Dim N As Long

Dim V As Variant

Dim Rng As Range



On Error GoTo EndMacro

Application.ScreenUpdating = False

Application.Calculation = xlCalculationManual



Col = ActiveCell.Column



If Selection.Rows.Count 1 Then

Set Rng = Selection

Else

Set Rng = ActiveSheet.UsedRange.Rows

End If



N = 0

For r = Rng.Rows.Count To 1 Step -1

V = Rng.Cells(r, 1).Value

If Application.WorksheetFunction.CountIf(Rng.Columns( 1), V) 1 Then

Rng.Rows(r).EntireRow.Delete

N = N + 1

End If

Next r



EndMacro:

Application.Calculation = xlCalculationAutomatic



'Comment: the code above works fine. The code below fails.



Sheets("LoadList Processing").Select '(Sheet 3)

Application.Goto Reference:="R1C2"

ActiveSheet.Range(Selection, Selection.End(xlDown)).Select

findstring = "Digibeta"

Set b = Columns(ActiveCell.Column).Find(What:=findstring,
LookAt:=xlWhole)

While Not (b Is Nothing)

b.EntireRow.Delete

Set b = Columns(ActiveCell.Column).Find(What:=findstring,
LookAt:=xlWhole)

Wend

Application.CutCopyMode = False





Sheets("LoadList Processing").Select '(Sheet 3)

Application.Goto Reference:="R1C3"

ActiveSheet.Range(Selection, Selection.End(xlDown)).Select

findstring = "Record"

Set b = Columns(ActiveCell.Column).Find(What:=findstring,
LookAt:=xlWhole)

While Not (b Is Nothing)

b.EntireRow.Delete

Set b = Columns(ActiveCell.Column).Find(What:=findstring,
LookAt:=xlWhole)

Wend

Application.CutCopyMode = False



'Comment: As noted in the message, all of this code works fine when run
from a macro created on and run from Sheet 3.


 
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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM


All times are GMT +1. The time now is 10:31 PM.

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

About Us

"It's about Microsoft Excel"