+ Reply to Thread
Results 1 to 4 of 4

Code correction

Hybrid View

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

    Code correction

    HI below code


    re arranges the data from tab "site assumptions" into " Capitalization"

    it says when Renovation or new built add in column F "Engineers" and "site finders"


    i made a mistake, when is new built the above is true

    however when is Renovation it needs to add only "Engineers" in column F not "site finders"

    please find attached. thanks in advance


    Sub CAPITALISATION():
    Dim n As Long, C As Long, Ac As Long, Ray As Variant, t
      t = Timer
      Ray = Sheets("SITE_ASSUMPTIONS").Range("p9").CurrentRegion
        ReDim nray(1 To UBound(Ray, 1) * 2, 1 To 6)
            For n = 2 To UBound(Ray, 1)
                If Ray(n, 4) = "New built" Or Ray(n, 4) = "Renovation" Then
                    C = C + 1
                    For Ac = 1 To 5
                         nray(C, Ac) = Ray(n, Ac)
                         nray(C, 6) = "Engineers"
                      Next Ac
                      C = C + 1
                      For Ac = 1 To 5
                        nray(C, Ac) = Ray(n, Ac)
                        nray(C, 6) = "Site Finders"
                    Next Ac
                End If
    Next n
    With Sheets("CAPITALISATION")
        .Cells(1).CurrentRegion.Offset(1).ClearContents
        .Range("A2").Resize(C, 6) = nray
    End With
    
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Code correction

    Try this code...
    Sub CAPITALISATION():
    Dim n As Long, C As Long, Ac As Long, Ray As Variant, t
      t = Timer
      Ray = Sheets("SITE_ASSUMPTIONS").Range("p9").CurrentRegion
        ReDim nray(1 To UBound(Ray, 1) * 2, 1 To 6)
            For n = 2 To UBound(Ray, 1)
                If Ray(n, 4) = "New built" Then
                    C = C + 1
                    For Ac = 1 To 5
                         nray(C, Ac) = Ray(n, Ac)
                         nray(C, 6) = "Engineers"
                      Next Ac
                      C = C + 1
                      For Ac = 1 To 5
                        nray(C, Ac) = Ray(n, Ac)
                        nray(C, 6) = "Site Finders"
                    Next Ac
                End If
                If Ray(n, 4) = "Renovation" Then
                     C = C + 1
                     For Ac = 1 To 5
                        nray(C, Ac) = Ray(n, Ac)
                        nray(C, 6) = "Engineers"
                    Next Ac
                End If
                     
    Next n
    With Sheets("CAPITALISATION")
        .Cells(1).CurrentRegion.Offset(1).ClearContents
        .Range("A2").Resize(C, 6) = nray
    End With
    
    End Sub
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

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

    Re: Code correction

    Perfect works like heaven

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Code correction

    Glad it worked for you.

+ 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. [SOLVED] vba code correction
    By antonio32 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2017, 02:38 PM
  2. [SOLVED] vba code correction
    By antonio32 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2017, 02:37 PM
  3. [SOLVED] vba code correction 2
    By antonio32 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2017, 02:23 PM
  4. [SOLVED] vba code correction
    By antonio32 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2017, 08:39 AM
  5. [SOLVED] Correction in code
    By Mart Marti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2016, 01:30 PM
  6. [SOLVED] need correction in code
    By ccsmith in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2012, 06:14 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