+ Reply to Thread
Results 1 to 4 of 4

Offset for VBA

  1. #1
    Registered User
    Join Date
    12-26-2016
    Location
    Mopti
    MS-Off Ver
    2010
    Posts
    10

    Offset for VBA

    Morning,
    Please can some one help me about VBA code.
    In fact, I'd like to write a vba script using offset command but I don't know how to implement it:
    A6=(3 or 4 or 5 or 6)
    in sheet2 I'd like to fill the next cells(on the same line) according to a condition based on the content of the first cell(sheet2!B2) :
    Condition :
    cas1 A6=3
    if sheet2!B2="X" then write X in the 7th cell from the cell B2
    if not
    if sheet!B3="X" then write X in the third and fourth field from cell B3
    if not
    if sheet!B4="X" then write X in the sixth and the third and seventh field from cell B4
    if not
    if sheet!B5="X" then write X in the second cell from B5 and seventh field from cell B4
    and so on for each week
    end
    Cas2 A6=4
    if sheet2!B2="X" then write X in the 11th cell from the cell B2
    if not
    if sheet!B3="X" then write X in the third and fourth field from cell B3
    if not
    if sheet!B4="X" then write X in the sixth and the third and nineth field from cell B4
    if not
    if sheet!B5="X" then write X in the second cell from B5 and seventh field from cell B4
    and so on for each week
    end
    Cas3 A6=5
    if sheet2!B2="X" then write X in the 15th cell from the cell B2
    if not
    if sheet!B3="X" then write X in the third and fourth field from cell B3
    if not
    if sheet!B4="X" then write X in the sixth and the third and nineth field from cell B4
    if not
    if sheet!B5="X" then write X in the second cell from B5 and seventh field from cell B4
    and so on for each week
    end
    Cas4 A6=6
    if sheet2!B2="X" then write X in the 19th cell from the cell B2
    if not
    if sheet!B3="X" then write X in the third and fourth field from cell B3
    if not
    if sheet!B4="X" then write X in the sixth and the third and nineth field from cell B4
    if not
    if sheet!B5="X" then write X in the second cell from B5 and seventh field from cell B4
    and so on for each week
    end

    each week has 28 columns that must be field following this role.
    Thanks

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Offset for VBA

    Hello maliwari,

    Please attach a sample workbook.

    Make sure there is just enough data to demonstrate your need.

    Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate.

    Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    12-26-2016
    Location
    Mopti
    MS-Off Ver
    2010
    Posts
    10

    Re: Offset for VBA

    Hi!
    Attached you've the file as requested.
    What I need to do :
    1. The other tables take their contents in the first table which are filled from the first sheet(MENU PRINCIPAL)
    2. The cells from G6 to AD6 are fiels according to the formula I submited earlier in the forum
    case1 : MENU PRINCIIPAL!J5=3
    IF C6="X" then I6="X"
    ELSEIF D6="X"then G6="X"
    elseif E6="X" then H6="X"
    elseif F6="X" then M6="X"
    Case 2 : MENU PRINCIPAL!J5=4
    IF C6="X" then M6="X"
    ELSEIF D6="X"then G6="X"
    elseif E6="X" then H6="X"
    elseif F6="X" then Q6="X"
    Case 3 : MENU PRINCIPAL!J5=5
    IF C6="X" then Q6="X"
    ELSEIF D6="X"then G6="X"
    elseif E6="X" then H6="X"
    elseif F6="X" then U6="X"
    Case 4 : MENU PRINCIPAL!J5=6
    IF C6="X" then U6="X"
    ELSEIF D6="X"then G6="X"
    elseif E6="X" then H6="X"
    elseif F6="X" then Y6="X"

    3. The other agents take their formula from the first agent
    4. The other tables are filled from the formula continuing the formula in the first table(I mean as the cells from G6 to AD6 are filled according to the X in C6, or D6, or E6, or F6; the next table are filled according to the X in the last 4 cells of the previous table(I mean the row under Sanday(Dimanche in french)),
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-05-2016, 01:11 PM
  2. Select offset variable offset cells
    By papasmurfuo9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2014, 06:12 AM
  3. Replies: 3
    Last Post: 06-01-2014, 10:26 AM
  4. [SOLVED] SpeedUp/Alternative to Offset.Value = Offset.Value
    By Jovica in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2013, 01:43 AM
  5. function similar to offset to offset the offset
    By Jerseynjphillypa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2012, 03:07 PM
  6. Reformatting - insert formula with offset, then offset to next cell
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2011, 05:41 AM
  7. Replies: 7
    Last Post: 11-04-2008, 06:41 AM

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