Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PVT PVT is offline
external usenet poster
 
Posts: 19
Default need help fixing macro

Hi- can you please help me fix the following macro. It "hangs" when
"no" is chosen at the messagebox. How do I make it go to the next cell
in the "if" statement?

Sub DeleteSearchTerm26()
Dim c As Range

With ActiveSheet.Range("A:A")
Do

Set c = .Find("by", LookIn:=xlValues, lookat:=xlPart, _
MatchCase:=False)

If c Is Nothing Then Exit Do
c.Select

If MsgBox("Delete entire row?", vbYesNo) = vbYes Then
c.EntireRow.Delete Else ActiveCell.Offset
(0,1).Select


Loop
End With

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default need help fixing macro

Put this in place of your If/Then

If MsgBox("Delete entire row?", vbYesNo) = vbYes Then
c.EntireRow.Delete
Else
ActiveCell.Offset(0, 1).Select
Exit Do
End If


"PVT" wrote:

Hi- can you please help me fix the following macro. It "hangs" when
"no" is chosen at the messagebox. How do I make it go to the next cell
in the "if" statement?

Sub DeleteSearchTerm26()
Dim c As Range

With ActiveSheet.Range("A:A")
Do

Set c = .Find("by", LookIn:=xlValues, lookat:=xlPart, _
MatchCase:=False)

If c Is Nothing Then Exit Do
c.Select

If MsgBox("Delete entire row?", vbYesNo) = vbYes Then
c.EntireRow.Delete Else ActiveCell.Offset
(0,1).Select


Loop
End With

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default need help fixing macro

Adding to Barb's comments, your Do Loop will be an infinite loop withou
specifying Until or While with eithe the Do or the Loop. i.e.

Do Until 'Something
Do While 'Something
Loop Until 'Something
Loop While 'Something

The Something needs to be a value or the absence of a value that the loop
will logically find. As it is written, it goes nowhere and checks nothing,
so it will just loop.

"PVT" wrote:

Hi- can you please help me fix the following macro. It "hangs" when
"no" is chosen at the messagebox. How do I make it go to the next cell
in the "if" statement?

Sub DeleteSearchTerm26()
Dim c As Range

With ActiveSheet.Range("A:A")
Do

Set c = .Find("by", LookIn:=xlValues, lookat:=xlPart, _
MatchCase:=False)

If c Is Nothing Then Exit Do
c.Select

If MsgBox("Delete entire row?", vbYesNo) = vbYes Then
c.EntireRow.Delete Else ActiveCell.Offset
(0,1).Select


Loop
End With

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
Fixing the date format in a macro or VBA Geoff B Excel Worksheet Functions 1 September 7th 09 11:00 AM
Help Fixing a Macro mg_sv_r Excel Programming 2 January 24th 08 05:51 PM
Fixing macro to choose a blank row [email protected] Excel Programming 4 May 14th 06 07:07 PM
Fixing SSN's with a macro Bruce Martin Excel Programming 5 June 18th 05 06:36 AM
Help Fixing Coloring Macro Tysone Excel Programming 2 January 20th 05 06:25 PM


All times are GMT +1. The time now is 04:33 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"