Results 1 to 6 of 6

Dynamic variables

Threaded View

  1. #1
    Registered User
    Join Date
    07-18-2008
    Location
    Ottawa
    Posts
    11

    Dynamic variables

    Hello, I'm new to the forum. Hope i can help!

    Im writing a macro that takes a list of raw data and sorts it in two levels; first by project number then by person. The paramter being sorted is how many hours they worked on a project. These are my fields:

    excell row number- Project Number - Person - Hours
    1 - 12345 - Timothy Dalton - 4
    2 - Rick Allen - 10
    3 - Rowan Atkinson - 12
    4
    5


    My raw data looks like this:

    Project Number- Person - Hours- row number
    12345 - Timothy Dalton - 4 - 1
    12345 - Rick Allen - 10 - 2
    12345 - Rowan Atkinson - 12 - 3


    I've written a macro that sorts these records but I would like to automate the program further by removing the row number. What i want to do is have the program read the person's name in the raw data, then search the list and either enter in the number of hours in the correct place, or if the person's name is not found in the list, add it (i have a counter containing the number of entries per project and a "row starting" entry for each project)

    i want to add a new entry via the insertion formula:

    Rows("18:18").Select
    Range("B18").Activate
    Selection.Insert Shift:=xlDown
    Now the problem here is that i need to dynamically indicate the row number when the program is run. If the persons name is not found then the program will insert a new line at the bottom of the entries and then enter in the new information. A variable will act as a pointer to the row numbers so i want the code to be:

    Rows("k:k").Select
    Range("Bk").Activate
    Selection.Insert Shift:=xlDown
    Where K is my pointer, but this doesnt work, so how i can i dynamically indicate the row where i want to insert a line, or is there a better way to go about this?
    Last edited by VBA Noob; 07-21-2008 at 02:11 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1