Find And Delete Depending On Answer To Msgbox Then Continue Loop

Jun 5, 2012

I am trying to build a macro that will search a column for the word "TEST" and when it finds that word it needs to prompt the user with a YesNo message box (or something similar) if they would like to delete the entire row that contains TEST. If Yes is selected, it should delete the row and continue on to find the next TEST in the column and repeat this process. If the user selects No, it should continue on to find the next TEST in the column and repeat this process.

View 4 Replies


ADVERTISEMENT

Determine MsgBox Answer

Dec 15, 2006

The macro I am working on will ask the user if they wish to transfer data to one of two Forms, held in two separate worksheets. The worksheet names are Record Form Games 3583 & Record Form PE 3581. The msgbox will ask "Is the data being transferred to Record Form 3583?" If Yes the sheet "Record Form Games 3583" will be set as the sheet as the one to transfer data to. If no "Record Form PE 3581" will be the destination sheet. This is what I have so far:

Sub Do_Admin()
Dim Record_Form As Worksheet
Msg = "Is the data being transferred to Record Form 3583?"
ans = MsgBox(Msg, vbYesNo)
If ans = vbYes Then Set Record_Form =
Sheets(Sheet"Record Form Games 3583")
End Sub

View 2 Replies View Related

Msgbox That Will Prompt For Answer Before Running Code

Apr 28, 2009

I need a MsgBox that will prompt for a Yes or No response. If you answer Yes run the code below if you answer no just stop and leave me in the current sheet.

View 10 Replies View Related

How To Continue For Loop

Jan 29, 2013

In Visual Basic, the Continue For statement will complete the current iteration and start the next, if any.

Code:
For i = 1 to 10
...do some work
If [some condition] then Continue For
...do the rest of the work
End For

This statement gets flagged as invalid in VBA.

What's the proper way to end just the current iteration of a For loop in VBA without exiting the loop entirely (Exit Loop)?

View 3 Replies View Related

Function Macro Debug: Continue Onto The Do Loop At The Bottom That Does All The Work

Aug 9, 2006

I am having a problem with a custom funciton I am trying to create. It will exit after it is finished with the IF Then Else statement. I need it to continue onto the Do loop at the bottom that does all the work.

Function UPCECheck( num As String) As Long
Dim CheckNum As Long
Dim TempCheck As Long
Dim X As Long
Dim Holdtxt As Variant
UPCECheck = 0
CheckNum = 0
Debug.Print Len(num)
If Len(num) = 12 Then
Holdtxt = num
ElseIf Len(num) < 12 Then
Holdtxt = "000000000000" & num
Holdtxt = Val(Mid(Holdtxt, Len(holdtext) - 12, 12))
End If...................

View 6 Replies View Related

Find Data And Delete Remaining Rows (For Each Loop)

Apr 24, 2009

In the code below I find rows containing "$$ #" at the far left and process it.
For all the remaining rows I want to delete the entire row, my macro only deletes some rows. Obviously I am not grasping something about looping throught the rows to delete unwanted data.

View 2 Replies View Related

Conditional Format (vba Loop Is The Answer)

Oct 21, 2009

i have 3 columns and hundreds of rows.... i first applied conditional format to the first row (A1, B1, C1) only. no problems so far as A1 has value '0' which is minimum and B1 is the highest value '200' and C1 is variable value between 200' and 0'. Im using icon sets in this one.... now i want the below rows to have the same conditional format.... how do i do that because when i select them all rows and columns and try to apply conditioanl formatting the outcome is not the same as i got previously in the first row...it somehow combines all the values rather working only on the individual row. i hope u get wat im tryin to say....

i come across a solution in my mind to give a loop in vba to do the conditional formatting each row seperately untill empty cell of column no. 4.... but doing this will obviously eat lot of memory in excel cause of each row will have a seperate conditional format.....

View 9 Replies View Related

Delete Sheet If A2 Is Blank And Then Continue MACRO

Nov 20, 2007

I have been able to put together a pretty hefty MACRO. I found out that some of the files I am importing may result in no data due to the manipulations I am doing. This causes a problem when I try to subtotal the data on each sheet. Is there a way to have the MACRO delete a sheet if cell a2 is blank and then continuw with the rest of the MACRO?

View 9 Replies View Related

Find Specific Character - Copy Into Next Row & Continue

Mar 13, 2008

I have an excel file in which the cell has more than 3000 entries, like following. I would like to copy the contents before ";" to next row & continue.

Question:

CN=123,CN=12,CN=ABC,CN=AB,;CN=345,CN=34,CN=CDF,CN=DC,;CN=510,CN=51,CN=PQR,CN=PQ;

Answer should be in excel:
CN=123,CN=12,CN=ABC,CN=AB
CN=345,CN=34,CN=CDF,CN=DC
CN=510,CN=51,CN=PQR,CN=PQ

I do not know how can I achieve this through "Macro". I would like to detect ; in the cell & copy the contents before/after it in the next rows & continue till the last figure.

View 9 Replies View Related

To Assign A Counter To The MsgBox- Exit Loop

Aug 31, 2007

This loop is to find if there is the string "Need Parent " in the range. If so the Msgbox notifies the user.

After it finds the string, the loop needs to exit- I tried to assign a counter to the MsgBox, but no go....

For i = 6 To lLrw
If Range("D" & i).Value = "Need Parent" Then
MsgBox "Stop. Parent Records Still Need To Be Created."
End If
ii = MsgBox + 1
If MsgBox > 0 Then Exit For
End If
Next i

View 9 Replies View Related

If Certain Answer In Cell Then Find / Show All Other Instances

Nov 15, 2013

Why than going line by line on a document that has 60k rows!

I have a document with NAMES in column A and ROLES in column I. If the user has more than one role..their name will be listed in "A" for each role in "I". I'm trying to purge down a file that has 60k + rows. Lets say i want to see all the people and all their roles if they are in "PROGRAMMER_ANALYST" role...can this be done by macros? or formula?

View 2 Replies View Related

If Row 1 Equals To Row 2 Then Delete Row 2 Else MsgBox

May 6, 2014

I'm trying to input a check into my macro. Basically the logic I'm trying to follow is:

If Row 1 = Row 2 then delete row 2,

ElseIf Row 1 Row 2 then Display MsgBox "Row 1 and Row 2 are different. Do you wish to continue?"

If user selects yes, resume

If user selects no, end sub and display MsgBox "Macro ended. Please correct changes manually"

View 6 Replies View Related

Store Row Number Within Loop And Delete All Stored Rows After Loop?

Sep 11, 2013

I have working code that returns a row number within a for loop based on parameters I set.

Each time the for loop runs I would like to store this row number, then after the loop has finished, delete all stored rows.

Code:
for rowNum = 1 to x (some variable end row number which I already have worked out using End(xlUp).Row)
if x = y then
*storedRow = rowNum
end if
next rowNum
*

Lines with a * are the bits I can't work out. I've been trying to understand arrays by reading posts on what other people have done, but I can't fit (or fully understand) the reDims, or reDim preserves into my code. I've seen what appear to be quite complex ways involving uBounds and LBounds, but unfortunately I can't see how to use them.

All I want is to simply keep adding a row numbers to a variable, (i.e. row 2, 5, 20, 33, 120, etc) and then delete those specific rows.

View 4 Replies View Related

Highlight Third Duplicate With Msgbox To Ask To Delete

Sep 16, 2009

I'm during a spreadsheet for the Local Government and the task is Hard Rubbish Collection. Residents only allow to have their hard rubbish collected twice a year but sometimes, some cheeky residents have their rubbish collected for the third time in a year without us knowing it

This is the code I've found in this forum (thanks to rylo) but it only works on active sheet ...

View 10 Replies View Related

Find (PR) In Column O Then Color Cell And Msgbox

Jun 9, 2014

I would like a sub (Like a Private Sub) that would automatically activate when certain text is pasted into the sheet.

Data is pasted to this spreadsheet starting on row 27 and can be several hundred rows of data.

Column O (15) is for Abbreviated States i.e. TX, ID, WA, etc.

If in column O "PR" is pasted then ...

1. Msgbox ("Alert")

2. Color the cell - Interior.ColorIndex = 46 'Orange

View 5 Replies View Related

Find A File And Present Its Location (Path) In A MsgBox

Jun 5, 2006

I am looking for a VBA Code which will:

1. Search for a specific File.

The file will the same file (ABC.xls) BUT the user might want to change it by typing a new name & Extension in the first Inputbox.

2. A second InputBox (Drive & Path) should now Pop-up.

If it will be left empty - the search should take place throughout ALL the installed HDs.

If the user decides to minimize the search range he/she will type a Drive & Path, the search should reduce/constrain itself to the specific Path ONLY.

My task is to show its Path location in a MsgBox (or to show "file not found")

It might be a good idea if the code can be extended beyond presenting the Path to:
1. Open the Windows "Explorer" (or "My Computer") in the specific Path with the file being selected (marked).

2. Opening that file, in "Excel", upon finding it.

A 3 section, VBA, code will be more than appreciated.

View 9 Replies View Related

For Each Loop To Delete Row W/ Value (Loop Backwards)

Aug 2, 2007

For Each loop can be instructed to loop starting the bottom of the range. I know that a For To Loop can handle looping from the bottom up,

Sub Filterout()
Dim c As Range
Dim rng As Range
Dim i As Long
Dim lrow As Long
Dim counter As Integer
lrow = Cells(Rows.Count, 3).End(xlUp).Row
Set rng = Range("c2:c36")

For Each c In rng
If Left(c.Value, 1) "~~" Then
c.EntireRow.Delete
End If
Next c

View 9 Replies View Related

Delete Columns Depending On Number Of Rows

Jun 5, 2014

I have a workbook, with a worksheet "Summary". In this worksheet "Summary" I would like to delete all columns that have less than 100 rows.

Please see the attached file : Summary.xlsx‎

View 3 Replies View Related

Delete Worksheets Depending On The Number Of Rows?

Jul 1, 2014

I have a workbook has many worksheets, I would like to be able to delete worksheets if, for example, the number of rows in the worksheet is less than 100 rows.

View 3 Replies View Related

Delete Entire Row Depending On The Contents Of A Cell

Jan 20, 2009

I'm trying to write a procedure which will search the contents of Column B of my worksheet for the word "Total". Whenever the word "Total" is found in a cell within Column B, the entire row should be deleted.

View 5 Replies View Related

List Box Depending On Combobox And Add Or Delete Items To Range

Jul 4, 2009

i had a user form with a Combo box,list box,text box and a command button. I need the code that works upon selecting:

1)An Item from the combo box should display the list in the list box.

eg: If Country is selected from the combobox then the list box should contain all the names of the countries from the country Column

2)An item should be added to the list in the worksheet when an item is entered in the textbox.

Like wise, when an item is selected from the combobox from "Delete Items List" all the items relating to the item selected from the combobox should be displayed in the list box and a choice to delete the items relating to the combobox item should be provided.

View 4 Replies View Related

Find Format: Find Method And Combine It With A Countif Or Loop

Feb 20, 2007

I'm trying to use this Find Method and combine it with a countif or loop. Something that will count a number of occurences of a unique type of character. I'm looking to find all "F" characters in Bold, Italic and Size 16. Here's my find code that I'm trying to use. I can get it to work by itself but not along with a countif or loop.

Sub count_4()
Dim r As Range
Set r = Range("A1:A6")
With Application.FindFormat.Font
.Bold = True
.Italic = True
.Size = 16
End With
r.Find(What:="F", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, searchformat:=True, MatchCase:=True).Activate
End Sub

View 4 Replies View Related

Find Data Depending On Two Criteria

Nov 9, 2009

I Have want two find the dates and the data of these dates
depending on the two criteria i have

note"the two criteria would be left(b3,4) and right (b3,4)

ex
in f3"date" i want to find the dates correspond with these two criteria
and then find the data of these dates in G3 Depending on the two criteria too.

Sheet1

ABCDEFG2DateData
Criteria1Criteria2DateResult31/1/2008M111 GG1G M113
M191M1131/2/2008M191 G1GG M11341/2/2008M191 G1GG M113

1/5/2008M191 G78GG M11351/2/2008M111 GG1G M113

1/8/2008M191 G1G9G9 M11361/3/2008M141 GG5G M113

71/4/2008M118 GG6G M113

81/5/2008M191 G78GG M113

91/5/2008M141 GG5G M113

101/6/2008M111 GG2G M113

View 9 Replies View Related

Loop: Macro To Go Through The Table And Preform An Operation In The Corresponding Cell In Column B Depending On The Value In Cell A

Mar 27, 2007

I have 2 columns and 10 rows (A1:B10). In column A are certain text values. How do I write a macro to go through the table and preform an operation in the corresponding cell in column B depending on the value in cell A? for example, if A3 = "Complete", overwrite the formula in B3 with the value (paste value)?

View 2 Replies View Related

Loop To Select And Delete A Row

Jun 21, 2012

Below is the loop. An error occurs at Rows("y:y").Select

The y value that would be found in cell C500 would always match the row that would be selected and deleted. For example if cell C500 had the value 13, I would want Rows("13:13").select and then deleted.

Sub Macro2()
'
' Macro2 Macro
'
'
For y = 1 To 100

[code]......

View 5 Replies View Related

VBA Loop And Delete 15 Rows

Sep 10, 2013

I have output from mainframe that is copy/paste to an excel workbook. I need to have VBA loop and delete the 15 rows. This is mainframe output so it will always be 15 rows

Count
Campus
Name
Course
Start Date

1
336001
Student1
1
9/2/2003

[Code] ............

View 1 Replies View Related

Entirerow Delete - Loop

Oct 3, 2008

Within my loop I would like to delete an entire row - but as my loop goes down each row one by one as soon as one row is deleted the next row moves up and is then not included in the loop.

Dim Rng As Range, Last As Integer, Dn As Range
Sheets("ttool").Select
Last = Sheets("old ttool").Range("J" & Rows.Count).End(xlUp).Row

Set Rng = Range(Range("J2"), Range("J" & Rows.Count).End(xlUp))

For Each Dn In Rng
If Dn "" Then
Last = Last + 1
Sheets("old ttool").Rows(Last).Value = Dn.EntireRow.Value
Dn.EntireRow.Delete
End If
Next Dn

If I run it 4 times it completes as it should. Or if I change it to entirerow.clearcontents all rows are cleared.

View 9 Replies View Related

Loop To Delete Empty Row

May 12, 2006

How do I make a loop to delete a row if the cell A is empty. Example: If cell A3 was empty I want it to delete the row. If cell A4 had data I would like it to skip that row and go on to cell A5.

View 6 Replies View Related

Loop To Delete Row When Criteria Is Met

Jul 13, 2006

I am using this to delete rows from my excel sheet. I basicaly start my script by placing xxx in cell B2000. I want to optimize my code and maybe some how tell excel do until last cell. I am playing with:

"Do Until lLastRow = Range("B" & Rows.Count).End(xlUp).Row"
But not shure how to procede with this.

Range("B1").Select
Do Until ActiveCell = "xxx"
If ActiveCell = "Ticket" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

View 2 Replies View Related

For Loop And Delete Entire Column

Oct 1, 2012

I have two worksheet. One worksheet (ws1) contains a list of item I want. The other sheet (ws2) contains multiple columns where the header (row 6) is named by item name.

I have the following code which deletes the entire column if the header name is not in the list contained in ws1 :

VB:
Sub delete_col()
Dim wanted As Boolean
Set ws1 = Workbooks("test1").Sheets("aaa")

[Code]....

First of all, this loop does not work properly since deleting the entire column shift them on the left, so when I first analyze column 11, if I delete it and then analyze column 12, the real column 12 now became column 11 and so on...

Secondly, this code is pretty slow. I am pretty sure I don't have to loop through my initial item list everytime I do Instr on a new column.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved