ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Msg Box to change Macro criteria? (https://www.excelbanter.com/excel-programming/334814-msg-box-change-macro-criteria.html)

John

Msg Box to change Macro criteria?
 
I found the following code on this website and have been using it for a
while. The code deletes rows that I have identified as duplicate rows. Now,
my spreadsheet is getting rather large and I was wondering if there is a way
to start a msg box or something that would allow me to enter what rows in my
column I want to run the macro on... rather than run the code over the
thousands of rows I want to keep already. The code is below.

Thanks for the help.


Sheets("USA Firms").Select

Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Columns(3)

Set rngFound = rngToSearch.Find("-")
If rngFound Is Nothing Then
MsgBox "No Deletions Found"
Else
Do
rngFound.EntireRow.Delete

Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
End Sub

John

Msg Box to change Macro criteria?
 
I have fixed my problem Thanks!

"John" wrote:

I found the following code on this website and have been using it for a
while. The code deletes rows that I have identified as duplicate rows. Now,
my spreadsheet is getting rather large and I was wondering if there is a way
to start a msg box or something that would allow me to enter what rows in my
column I want to run the macro on... rather than run the code over the
thousands of rows I want to keep already. The code is below.

Thanks for the help.


Sheets("USA Firms").Select

Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Columns(3)

Set rngFound = rngToSearch.Find("-")
If rngFound Is Nothing Then
MsgBox "No Deletions Found"
Else
Do
rngFound.EntireRow.Delete

Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
End Sub



All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com