I'm trying to write a macro that will keep track of sales/commissions. I have written a simple macro that will ask the user for data using input boxes, and place that data into an inserted line. The sheet is divided into two areas, one above the other. To sort the first set of sales by invoice number, I wrote a macro to look for data beyond line 3 to the first blank line and sort by column A. However, I do not know how to make it sort the lower data because the data does not always start on the same row. If there are many rows in the top section, the lower section gets pushed farther down the sheet. The first cell of the sort point is one cell below the second time the word "Invoice" appears on the sheet. Can I write a macro to return a number that represents the row after the second time the word "Invoice" appears in column A?
How to return a number that represents the row after certain criteria is met?
Collapse
X
-
-
Code:Sub Find_Invoice() Range("A1").Activate Cells.Find(What:="Invoice", After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase _ :=True, SearchFormat:=True).Activate Cells.FindNext(After:=ActiveCell).Activate ActiveCell.Offset(1, 0).Activate MsgBox "Row= " & ActiveCell.Row End Sub
Comment