+ Reply to Thread
Results 1 to 9 of 9

if else loops excel vba code required

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    if else loops excel vba code required

    looking for some vba excel code that does the following

    document 2 worksheets

    sheet 1 called "master project register" which has hundred rows (project names) and 6 columns named as follows

    column a = project name
    column b = segement
    coumn c = date
    column d = go live
    column e = project close
    column f = live project

    sheet 2 is called "import to project " and has only the above headings from column a to f

    i want to do the following in excel for each row in master project register worksheet

    1. if column F = Yes
    than do the following

    note if doesnt = yes than move onto next row etc


    2. copy row and paste into "import to project " workseet
    3. ihighlight row 2 and insert2 rows directly beneath the pasted data.
    4. in column a in first empty row in cell a2 write " go live"
    5.in column a in second empty row in cell a3 write " project close"
    6. copy the segment name down from b1 into b2 and b3

    7.copy d1 into c2

    8.copy e1 into c3

    9. highlight row 1 and insert empty row ( ready for the next set of data to be inserted)

    the above code will repeat steps for every project in the master worksheet looking for any "yes" in column f and repeating steps 2-9

    appreciate your help guys.... im sure this is achievable....

    if anyone knows also how to write message at end to say " you have pasted x number of projects"

    x = projects with "Yes" in column F
    Last edited by razwan1978; 02-08-2009 at 05:08 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: if else loops excel vba code required

    So what have you tried so far? Attach an example workbook.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: if else loops excel vba code required

    hi thanks for the quicky response

    the document i have is at work steps 2-9 i think can be recorded as macro

    but not sure how to incorporate the if statement to say only run the code if in for that row column f has yes value

    if not goto next row etc

    ps not sure how to attached the file to this thread as im new user

    any ideas

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: if else loops excel vba code required

    You can attach a file by clicking "Post Reply" then scroll down until you see the "Manage Attachments" button

  5. #5
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: if else loops excel vba code required

    hi please see attached file

    please note macro is called aaa

    i have done step 1 but need the code for step 2-9 before it says next

    appreciate your help roy on this
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: if else loops excel vba code required

    please note the when running the macroit pastes the information into import to project worksheet but deletes the headings. in row 1 ...any reason why??

  7. #7
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: if else loops excel vba code required

    hi roy please use latest zip file attached

    i have manage to create two macros...lol

    one is called "aaa" which apparently looks through the projects and copys rows with "yes" in column f - basically carries out step 1 and 2 but deletes the header titles. not sure why


    second macro is recorded one "called import to project " which carries out steps from 3-9.
    i need to combine the two but dont know how
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: if else loops excel vba code required

    Hi

    Based on your example file, try this.

    Please Login or Register  to view this content.
    rylo

  9. #9
    Registered User
    Join Date
    02-08-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: if else loops excel vba code required

    thanks roy

    will this code out and see if it works

    will it work if there are 100's of rows in sheet 1? ie 100's of projects ??

+ Reply to Thread

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