+ Reply to Thread
Results 1 to 2 of 2

Vba code correction to update figures

  1. #1
    Registered User
    Join Date
    03-07-2014
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    83

    Vba code correction to update figures

    Hi All

    in the following file Budget

    https://drive.google.com/file/d/0B6D...9aRjhNMjA/view

    I have to create a table based on

    1. A list of sites (variable number of sites)
    2. A list of costs (water, electricity, detergent, tank cleaning)
    3. Months ( Jan, FebÂ…December)

    the code will create/update a table where the user will input the all costs per month and site. table is located in tab “VARIABLE_COST”

    1. List of sites located in tab “site assumptions”: it is starts in cell P9. The user can insert new sites and/or delete sites
    2. List of costs located in tab "costs_list” starting in A2 and the user can add more costs to the current list
    3. Months located in tab “VARIABLE_COST” it is already input so nothing to do


    I have the following code which creates/updates the sites and costs in column A and B in tab “VARIABLE_COST” .
    it works well however is not dynamic if the user change the number of sites the costs rows wont move accordingly.

    if a site is deleted in tab "site assumptions" the rows related to that site in "Variable cost" must be deleted.

    Whether we add new sites or delete the table in "variable Cost" must be compact (no blank rows in between sites)

    [CODE]
    ub create_variable_costs_assumptions()

    Dim CostLst As Range
    Dim CostRws As Integer
    Dim usdrws As Long
    Dim i As Long
    Dim ValU As Range

    Application.ScreenUpdating = False
    CostRws = Sheet21.Range("A2").CurrentRegion.Rows.Count
    Set CostLst = Sheet21.Range("A2:A" & CostRws)


    i = 2
    For Each ValU In Sheet8.Range("P9:P" & Sheet8.Range("P9").End(xlDown).Row)
    Sheet12.Range("A" & i).Resize(CostRws - 1) = ValU
    Sheet12.Range("B" & i).Resize(CostRws - 1) = CostLst.Value
    i = i + CostRws - 1
    Next ValU

    Application.ScreenUpdating = False




    End Sub
    [CODE]

    thanks in advance!

  2. #2
    Registered User
    Join Date
    03-07-2014
    Location
    london
    MS-Off Ver
    Excel 2016
    Posts
    83

    Re: Vba code correction to update figures

    Please ignore this post i recreated in the VBA area sorry thanks

+ 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. Code correction
    By Indi_Ra in forum Excel General
    Replies: 0
    Last Post: 03-09-2016, 01:10 PM
  2. [SOLVED] Correction in code
    By Mart Marti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2016, 01:30 PM
  3. [SOLVED] need correction in code
    By ccsmith in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2012, 06:14 AM
  4. Vba Code Correction
    By tromao in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2007, 05:55 PM
  5. [SOLVED] VBA Code Correction
    By RichIT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2006, 12:10 PM
  6. VBA Code Correction
    By RichIT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2006, 11:35 AM
  7. Code Correction Need
    By Safi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2006, 01:10 PM

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