Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
need help to update macro to office 2007 macro enabled workbook | Excel Discussion (Misc queries) | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) |