vba courses london - counters excel

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba courses london - Counters in excel

vba courses london - Counters in excel

resolvedResolved · Low Priority · Version Standard

Ricci has attended:
Excel VBA Intro Intermediate course

Counters in excel

I have some data that I'm trying to produce a report from, I have a huge list of employee names that are duplicated and are in no order. I want 1 list of employees in alphabetical order with no repitions to use in a drop down list on a form. I remembered in my training the mention of counters, but I can't remember how to use them or how to incorporate this with a form.

Cheers,
Ricci

RE: Counters in excel

To create a list if employees with no duplicates do the following:

Record a macro to Select the Name column and sort it

Create a sheet for the new records "New Sheet"

Create a OldRow counter and set it to the first row of the names

Create a NewRow counter and set it to the row of the "New Sheet" where the records are going

On the Daata Sheet if the Names aree in Column 1 do the following:

Do a For counter loop taking into account the number of rows in the data

Cells(OldRow,1).Select

Copy it to the new sheet

Move New row down One

Add the value of the cell to a variable

move OldRow down one

Check if the value of Cell(OldRow,1) equals the Variable

If it does Move down One row

Else

repeat the copy routine and add the new name to the variable

With the above routine in mind You can look at the code On the disk in the manual and adapt the code in CopySalesRecords and the little routione to check for duplicate dates





 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Use GoTo to Select A Cell With VBA

To select a certain cell on a Worksheet you can use:

Application.Goto Reference:=Range("V300")

or more simply

Range("V300").Select

If, on the other hand, you want the selected cell to be the top/left cell on the screen you use:

Application.Goto Reference:=Range("V300"), Scroll=True

View all VBA hints and tips


Server loaded in 0.08 secs.