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




Reply With Quote
Bookmarks