PC Review


Reply
Thread Tools Rate Thread

Adding An If Clause after Prompt

 
 
kmzito@gmail.com
Guest
Posts: n/a
 
      13th May 2009
What the below macro does is prompt the user for a vendor, find the
vendor in the C column, confirms if this is the correct one, then
deletes that line.

What I'd like it to do is:
- Prompt the user for a vendor
- Find the vendor in C column
- Confirm that is the correct one to delete
- If the B column says monthly, delete 12... if the B column says
yearly, delete 1... if the B column says quarterly, delete 3..

I'm not sure if that is possible but it is ideal.



Sheets("list").Select
Range("C3").Select
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Select

Answer = MsgBox("Is this the contract/vendor you would like to
delete?", vbYesNo + vbInformation, "Please Confirm")
If Answer = vbYes Then
Selection.EntireRow.Delete
Exit Sub

Else
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
End If
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      13th May 2009
I did not test this, but it should work. Use the Select Case to test the
value in column B.

Sheets("list").Select
Range("C3").Select
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Select

Answer = MsgBox("Is this the contract/vendor you would like to
delete?", vbYesNo + vbInformation, "Please Confirm")
If Answer = vbYes Then
Select Case LCAse(Range("B" & Selection.Row).Value)

Case "monthly"
Selection.Resize(12, 1).EntireRow.Delete
Case "quarterly"
Selection.Resize(3, 1).EntireRow.Delete
Case "yearly"
Selection.EntireRow.Delete
End Select
Exit Sub

Else
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
End If



<(E-Mail Removed)> wrote in message
news:d505896a-0173-44bd-a548-(E-Mail Removed)...
> What the below macro does is prompt the user for a vendor, find the
> vendor in the C column, confirms if this is the correct one, then
> deletes that line.
>
> What I'd like it to do is:
> - Prompt the user for a vendor
> - Find the vendor in C column
> - Confirm that is the correct one to delete
> - If the B column says monthly, delete 12... if the B column says
> yearly, delete 1... if the B column says quarterly, delete 3..
>
> I'm not sure if that is possible but it is ideal.
>
>
>
> Sheets("list").Select
> Range("C3").Select
> Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
> LookAt _
> :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
> MatchCase:= _
> False, SearchFormat:=False).Select
>
> Answer = MsgBox("Is this the contract/vendor you would like to
> delete?", vbYesNo + vbInformation, "Please Confirm")
> If Answer = vbYes Then
> Selection.EntireRow.Delete
> Exit Sub
>
> Else
> Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
> LookAt _
> :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
> MatchCase:= _
> False, SearchFormat:=False).Activate
> End If



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding columns by prompt. =?Utf-8?B?UmFjaGVs?= Microsoft Access 3 17th Feb 2006 11:40 PM
Adding Parameters to WHERE clause in DataAdapter Mike D Microsoft C# .NET 3 17th Dec 2004 03:03 PM
Adding a WHERE clause to a Crosstab query Carl Rapson Microsoft Access Queries 2 22nd Oct 2004 03:18 PM
Re: Adding "And" clause in SQL string causing SQL Syntax error Jamie Collins Microsoft Excel Programming 2 8th Jul 2004 09:36 PM
Query skips input for Where clause if second table or query added or if prompt contains blanks in the prompt string =?Utf-8?B?SHVudGVy?= Microsoft Access Queries 0 18th Mar 2004 10:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:31 AM.