Results 1 to 9 of 9

Thread: Divide Rest of the Columns using Column A values

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    try

    Code:
    Option Explicit
    
    Sub kTest()
        
        Dim r   As Long, c  As Long
        Dim ColA, d, Dest As Range
        
        With Worksheets("Sheet1")
            r = .Range("a" & .Rows.Count).End(xlUp).Row
            c = .Cells(1, .Columns.Count).End(xlToLeft).Column
            ColA = .Range("a2:a" & r).Value2
            d = .Range("b2", .Cells(r, c)).Value2
            Set Dest = .Range("b2")
        End With
        
        If IsArray(ColA) Then
            If IsArray(d) Then
                For r = 1 To UBound(ColA, 1)
                    For c = 1 To UBound(d, 2)
                        If ColA(r, 1) = 0 Then
                            d(r, c) = "=iferror(" & d(r, c) & "/" & ColA(r, 1) & ",0)"
                        Else
                            d(r, c) = "=" & d(r, c) & "/" & ColA(r, 1)
                        End If
                    Next
                Next
                Dest.Resize(UBound(d, 1), UBound(d, 2)).Value2 = d
            End If
        End If
        
    End Sub
    Last edited by Admin; 12-17-2015 at 02:40 PM. Reason: code edited
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Concatenating your Balls
    By DocAElstein in forum Excel Help
    Replies: 26
    Last Post: 10-13-2014, 02:07 PM
  2. Replies: 10
    Last Post: 02-18-2014, 01:34 PM
  3. Replies: 6
    Last Post: 07-26-2013, 11:42 AM
  4. Replies: 10
    Last Post: 05-23-2013, 12:30 PM
  5. Replies: 4
    Last Post: 04-05-2013, 12:08 PM

Posting Permissions

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