Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping a Macro

Hello. I have created a very simple macro within Excel. It calculates the
sheet (F9) , then searches for a value ( F4 ) . It works, but I need it to
repeat this action continuously until it doe's NOT find the searched for
value. I am using Excel 2003. Thank you. Here is my code :

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/21/2007 by
'
' Keyboard Shortcut: Ctrl+z
'
ActiveSheet.Calculate
Selection.FindNext(After:=ActiveCell).Activate
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looping a Macro

I have no knowledge of programming or it's terms and phrases. I am hoping
that someone will advance me the correct code to make this macro repeat
itself. I had already looked in help but was not able to reach my goal.
Thanks.

"Blue Stars" wrote:

Hello. I have created a very simple macro within Excel. It calculates the
sheet (F9) , then searches for a value ( F4 ) . It works, but I need it to
repeat this action continuously until it doe's NOT find the searched for
value. I am using Excel 2003. Thank you. Here is my code :

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/21/2007 by
'
' Keyboard Shortcut: Ctrl+z
'
ActiveSheet.Calculate
Selection.FindNext(After:=ActiveCell).Activate
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Looping a Macro

What do you want to do with the found cells?

This macro will color them.

Sub findthings()
whatsit = ActiveSheet.Range("F4").Value
With ActiveSheet.UsedRange
Set c = .Find(whatsit, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < FirstAddress
End If
End With
End Sub


Gord Dibben MS Excel MVP


On Tue, 21 Aug 2007 19:58:00 -0700, Blue Stars
wrote:

I have no knowledge of programming or it's terms and phrases. I am hoping
that someone will advance me the correct code to make this macro repeat
itself. I had already looked in help but was not able to reach my goal.
Thanks.

"Blue Stars" wrote:

Hello. I have created a very simple macro within Excel. It calculates the
sheet (F9) , then searches for a value ( F4 ) . It works, but I need it to
repeat this action continuously until it doe's NOT find the searched for
value. I am using Excel 2003. Thank you. Here is my code :

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/21/2007 by
'
' Keyboard Shortcut: Ctrl+z
'
ActiveSheet.Calculate
Selection.FindNext(After:=ActiveCell).Activate
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looping a Macro

I have a column of cells that use the RANDBETWEEN function. Previously, I was
using the old Windows Recorder program with Excel to find a specific value
within the column-- "F9" to create a fresh batch of random numbers, then
"Shift F4" to find the specific value. I set the Recorder to "Continuous
Loop" so that it would repeat this hundreds of times until the searched for
value was NOT found.
The macro would stop with an error message, exactly what I wanted, as I have
a formula cell that counts the number of calculations that it required to
reach this state. I want an Excel macro to do this exact same thing. Is this
possible? Windows Recorder works for a while but has far, far too many errors
and stops to be practical in use. The purpose behind all this is for
probability research. Thank you.
"Gord Dibben" wrote:

What do you want to do with the found cells?

This macro will color them.

Sub findthings()
whatsit = ActiveSheet.Range("F4").Value
With ActiveSheet.UsedRange
Set c = .Find(whatsit, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < FirstAddress
End If
End With
End Sub


Gord Dibben MS Excel MVP


On Tue, 21 Aug 2007 19:58:00 -0700, Blue Stars
wrote:

I have no knowledge of programming or it's terms and phrases. I am hoping
that someone will advance me the correct code to make this macro repeat
itself. I had already looked in help but was not able to reach my goal.
Thanks.

"Blue Stars" wrote:

Hello. I have created a very simple macro within Excel. It calculates the
sheet (F9) , then searches for a value ( F4 ) . It works, but I need it to
repeat this action continuously until it doe's NOT find the searched for
value. I am using Excel 2003. Thank you. Here is my code :

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/21/2007 by
'
' Keyboard Shortcut: Ctrl+z
'
ActiveSheet.Calculate
Selection.FindNext(After:=ActiveCell).Activate
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
Looping Macro KimC Excel Discussion (Misc queries) 1 January 11th 10 04:55 AM
Looping Macro Jase Excel Discussion (Misc queries) 5 March 12th 08 09:08 PM
Looping macro RK Excel Worksheet Functions 2 December 12th 06 11:29 PM
Looping macro furanku Excel Programming 1 September 25th 05 07:25 AM
Need help with my looping macro Pete Excel Programming 1 March 17th 05 11:09 PM


All times are GMT +1. The time now is 02:57 AM.

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"