Additional Question in Macro?

bdunk

Active Member
Joined
Aug 1, 2002
Messages
290
I was wondering if I could get some help with the following macro code. The current code (shown below) asks the question "Do you want to delete any quantities from the TY(F) column?. They are then asked to confirm the value. If they click continue the macro runs and the appropriate rows are deleted. My question is this. Can I add an additional question that asks " Would you like to delete any quantities in column LY(E)?" Next, if a confirmation message could display showing the values the user entered with a "Continue" button and a "cancel" button.

So if the user enters 3 in the first question and 6 in the second question the rows with 3 or less in column F and 6 or less in column E would be deleted. Now if column F had a 4 in it and column E had a 4 the row would stay as it did not meet the criteria of both questions.

Thanks for the help
Brian

If MsgBox("Do you want to delete any quantities from the TY(F) column?", vbYesNo, "Delete rows?") = vbYes Then
'ask user for value
Qty = Application.InputBox("What quantities for this year(F) would you like to delete?" & vbCrLf & _
"", Type:=1)
'if cancel is clicked, ignore the next part
If Not Qty = False Then
'display confirmation msgbox
If MsgBox("All totals with a quantity of " & Qty & " or less " & _
"will be deleted." & String(2, vbCrLf) & "Do you want to continue?", _
vbYesNo + vbExclamation) = vbYes Then
Application.ScreenUpdating = False
'loop through the rows--starting from the last row and going up the column
'deleting rows that have value <=Qty in column F
For i = LastRow To 2 Step -1
If Cells(i, 6).Value <= Qty Then Rows(i).Delete
Next i
End If
End If
End If
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top