View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
bgkgmg bgkgmg is offline
external usenet poster
 
Posts: 40
Default Stop after IF Then

Invoice number in sheet(Enter)cell AM4. When i run macro the values I
assigned in invoice are copied to Sheet(Daily) in same row as corresponding
invoice number. After each invoice is copied I protected the sheet(Daily).
I want the invoice number in sheet(Enter) to increase in value by 1 after
macro is run. The current formula below does that but when I go to enter
next invoice the sheet is protected which will not allow me to copy data. I
think when invoice number is changed to 102, or next invoice, the macro
continues and protects sheet.

Sub Macro1()
'Macro1 Macro

If Worksheets("Enter").Range("AM4").Value =
Worksheets("Daily").Range("B4") Then
Worksheets("Daily").Range("C4").Value =
Worksheets("Enter").Range("AA9").Value
Worksheets("Daily").Range("D4").Value =
Worksheets("Enter").Range("AG6").Value
Worksheets("Daily").Range("E4").Value =
Worksheets("Enter").Range("AA11").Value
Worksheets("Daily").Range("G4").Value =
Worksheets("Enter").Range("AA15").Value
Worksheets("Enter").Range("AA9").Value = ""
Worksheets("Enter").Range("AG6").Value = ""
Worksheets("Enter").Range("AA11").Value = ""
Worksheets("Enter").Range("AA15").Value = ""
Sheets("Daily").Select
Range("C4,D4,E4,G4").Select
ActiveSheet.Unprotect
Sheets("Daily").Select
Range("C4,D4,E4,G4").Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End If

If Worksheets("Enter").Range("AM4").Value =
Worksheets("Daily").Range("B5") Then
Worksheets("Daily").Range("C5").Value =
Worksheets("Enter").Range("AA9").Value
Worksheets("Daily").Range("D5").Value =
Worksheets("Enter").Range("AG6").Value
Worksheets("Daily").Range("E5").Value =
Worksheets("Enter").Range("AA11").Value
Worksheets("Daily").Range("G5").Value =
Worksheets("Enter").Range("AA15").Value
Worksheets("Enter").Range("AA9").Value = ""
Worksheets("Enter").Range("AG6").Value = ""
Worksheets("Enter").Range("AA11").Value = ""
Worksheets("Enter").Range("AA15").Value = ""
Sheets("Daily").Select
Range("C5,D5,E5,G5").Select
ActiveSheet.Unprotect
Sheets("Daily").Select
Range("C5,D5,E5,G5").Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End If

If Worksheets("Daily").Range("D5").Value = "" Then
Worksheets("Enter").Range("AM4").Value = "102"
End If
etc..


"Don Guillett" wrote:

You need to explain this FIRST a bit further.
stop running after whichever If Then statement applies
first so other rows of If Then statements are not locked thus allowing me
to


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"bgkgmg" wrote in message
...
I'm running macro with many If Then statements. If Then applies to
matching
invoice numbers and then moving info to row on another sheet. I am
locking
cells that are involved on sheet2 and protecting worksheet after each one.
I
would like macro to stop running after whichever If Then statement applies
first so other rows of If Then statements are not locked thus allowing me
to
enter next statement.
I hope you understand question.
Thanks
Bobby



"Rick Rothstein" wrote:

As Mike said, it is hard to tell exactly what you doing without seeing your
code. However, when you say you want to stop "after whichever If Then
statement applies first" sounds like your code is looping down a column of
invoice numbers looking for a "current" invoice number and, once found, you
take action and then want to stop. If that is what you are doing, I think
you can eliminate the loop altogether and use the Find method (of a range)
to locate your "match", and then just do whatever you are doing to that
found reference.

--
Rick (MVP - Excel)


"bgkgmg" wrote in message
...
I'm running macro with many If Then statements. If Then applies to
matching
invoice numbers and then moving info to row on another sheet. I am
locking
cells that are involved on sheet2 and protecting worksheet after each one.
I
would like macro to stop running after whichever If Then statement applies
first so other rows of If Then statements are not locked thus allowing me
to
enter next statement.
I hope you understand question.
Thanks
Bobby