Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to run a macro in the background & how to end it?
I ran across a macro (see below) on this site by David McRitche which seems
to do what I want but, there are two things I would like the macro to do if possible? How can I edit this macro to do the following? 1. Have the macro run in the background. This macro ties up my cpu totally, I can't doing anything until I stop it!! 2. Have the macro end when it see's the first blank cell in column "A" of the master sheet. This macro just keeps running on, & on & on.... I have attempted to contact the author of this macro via email(no response) that is why I have returned.. I'm not sure if its my three year old PC (P4) or maybe the number of records I have but it seems to take a long time to run. I am running Windows XP Pro and Office 2003. I have a workbook that has two spreadsheets of data the master sheet (1) has 2,026 rows of data, the second sheet has 1,606 rows of data. I want to compare the item number in column "A" in the master sheet against the item number in column "A" in the second sheet. The purpose is to identify the duplicate numbers between the two. I am not a wiz at macros so any help would be greatly appreciated. David McRitche's macro: Sub FindDupes() 'assuming both sheets are in same book and book is open Dim sht1 As Worksheet Dim sht2 As Worksheet Dim cell1 As Range Dim cell2 As Range Dim str As String str = InputBox("Type name of first sheet") Set sht1 = Worksheets(str) str = InputBox("Type name of second sheet") Set sht2 = Worksheets(str) For Each cell1 In sht1.Columns(1).Cells For Each cell2 In sht2.Columns(1).Cells If cell2.Value = cell1.Value Then cell1.Interior.ColorIndex = 3 cell2.Interior.ColorIndex = 3 End If Next cell2 Next cell1 End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to run a macro in the background & how to end it?
VBA code is inherently synchronous.
Unless you employ some technique to extend this (may be with a timer), point #1 is not possible. #2 For Each cell1 In sht1.Columns(1).Cells if cells1.value="" then exit sub For Each cell2 In sht2.Columns(1).Cells NickHK "41db14" wrote in message ... I ran across a macro (see below) on this site by David McRitche which seems to do what I want but, there are two things I would like the macro to do if possible? How can I edit this macro to do the following? 1. Have the macro run in the background. This macro ties up my cpu totally, I can't doing anything until I stop it!! 2. Have the macro end when it see's the first blank cell in column "A" of the master sheet. This macro just keeps running on, & on & on.... I have attempted to contact the author of this macro via email(no response) that is why I have returned.. I'm not sure if its my three year old PC (P4) or maybe the number of records I have but it seems to take a long time to run. I am running Windows XP Pro and Office 2003. I have a workbook that has two spreadsheets of data the master sheet (1) has 2,026 rows of data, the second sheet has 1,606 rows of data. I want to compare the item number in column "A" in the master sheet against the item number in column "A" in the second sheet. The purpose is to identify the duplicate numbers between the two. I am not a wiz at macros so any help would be greatly appreciated. David McRitche's macro: Sub FindDupes() 'assuming both sheets are in same book and book is open Dim sht1 As Worksheet Dim sht2 As Worksheet Dim cell1 As Range Dim cell2 As Range Dim str As String str = InputBox("Type name of first sheet") Set sht1 = Worksheets(str) str = InputBox("Type name of second sheet") Set sht2 = Worksheets(str) For Each cell1 In sht1.Columns(1).Cells For Each cell2 In sht2.Columns(1).Cells If cell2.Value = cell1.Value Then cell1.Interior.ColorIndex = 3 cell2.Interior.ColorIndex = 3 End If Next cell2 Next cell1 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro in Background | Excel Discussion (Misc queries) | |||
How do I run a macro in the background | Excel Discussion (Misc queries) | |||
Macro that runs in the background | Excel Discussion (Misc queries) | |||
Run macro in background | Excel Programming | |||
running macro at the background | Excel Programming |