Sunday, July 22, 2018

Self Note on Range as variable

Sub CleaningData()

Dim targetName As Range

    For Each targetName In Range("A2:A147")
    
    Sheets("Customers").Range("D3").Value = targetName.Value
    
        If Range("D4") = 0 Then
        
            Range("j1").Formula = "=counta(F:F)"
            
            Dim r As Integer
            
            r = Range("J1").Value + 1
            
            Range("F" & r).Value = targetName.Value
            
            Range("G" & r).Value = targetName.Address
        
        End If
    
    Next targetName

End Sub

No comments:

Post a Comment

Autofilter: To filter with macro

Below is very basic macro to define filter on atable which has two columns. Name(Comuln A) and Dept(Column B). Function will filter all emp...